Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / whatsappInteraction / whatsappInteraction.events.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x765e=['../../mysqldb','WhatsappInteraction','WhatsappMessage','setMaxListeners','save','update','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','events'];(function(_0x433463,_0x54fc41){var _0x521d6c=function(_0x5b9f80){while(--_0x5b9f80){_0x433463['push'](_0x433463['shift']());}};_0x521d6c(++_0x54fc41);}(_0x765e,0x131));var _0xe765=function(_0x4c9396,_0x505bfd){_0x4c9396=_0x4c9396-0x0;var _0x584ab8=_0x765e[_0x4c9396];return _0x584ab8;};'use strict';var EventEmitter=require(_0xe765('0x0'));var WhatsappInteraction=require(_0xe765('0x1'))['db'][_0xe765('0x2')];var WhatsappMessage=require(_0xe765('0x1'))['db'][_0xe765('0x3')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xe765('0x4')](0x0);var events={'afterCreate':_0xe765('0x5'),'afterUpdate':_0xe765('0x6'),'afterDestroy':_0xe765('0x7')};function emitEvent(_0xd2e232){return function(_0x9559d4,_0x109713,_0x40ac5e){_0x9559d4[_0xe765('0x8')]({'attributes':['id'],'raw':!![]})[_0xe765('0x9')](function(_0x504542){_0x9559d4[_0xe765('0xa')](_0xe765('0xb'),_0x504542[_0xe765('0xc')](function(_0x2c1232){return{'id':_0x2c1232['id']};}));return WhatsappMessage[_0xe765('0xd')]({'where':{'WhatsappInteractionId':_0x9559d4['id'],'direction':'in','read':![]},'raw':!![]});})[_0xe765('0x9')](function(_0x89a285){_0x9559d4['setDataValue'](_0xe765('0xe'),_0x89a285[_0xe765('0xf')]);WhatsappInteractionEvents[_0xe765('0x10')](_0xd2e232+':'+_0x9559d4['id'],_0x9559d4);WhatsappInteractionEvents['emit'](_0xd2e232,_0x9559d4);_0x40ac5e(null);})[_0xe765('0x11')](_0x40ac5e(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module['exports']=WhatsappInteractionEvents;