Built motion from commit (unavailable).|2.5.4
[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 _0x4ffc=['then','map','findAll','unreadMessages','length','emit','exports','events','../../mysqldb','WhatsappInteraction','setMaxListeners','save','update','remove','getUsers'];(function(_0x4551f6,_0x48151b){var _0x581dc2=function(_0x1842af){while(--_0x1842af){_0x4551f6['push'](_0x4551f6['shift']());}};_0x581dc2(++_0x48151b);}(_0x4ffc,0x124));var _0xc4ff=function(_0x566585,_0x54183a){_0x566585=_0x566585-0x0;var _0x3bd63f=_0x4ffc[_0x566585];return _0x3bd63f;};'use strict';var EventEmitter=require(_0xc4ff('0x0'));var WhatsappInteraction=require(_0xc4ff('0x1'))['db'][_0xc4ff('0x2')];var WhatsappMessage=require('../../mysqldb')['db']['WhatsappMessage'];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xc4ff('0x3')](0x0);var events={'afterCreate':_0xc4ff('0x4'),'afterUpdate':_0xc4ff('0x5'),'afterDestroy':_0xc4ff('0x6')};function emitEvent(_0x59f848){return function(_0x2fac81,_0x3b073d,_0x49ec55){_0x2fac81[_0xc4ff('0x7')]({'attributes':['id'],'raw':!![]})[_0xc4ff('0x8')](function(_0x26cabe){_0x2fac81['setDataValue']('Users',_0x26cabe[_0xc4ff('0x9')](function(_0x588836){return{'id':_0x588836['id']};}));return WhatsappMessage[_0xc4ff('0xa')]({'where':{'WhatsappInteractionId':_0x2fac81['id'],'direction':'in','read':![]},'raw':!![]});})[_0xc4ff('0x8')](function(_0x4e067b){_0x2fac81['setDataValue'](_0xc4ff('0xb'),_0x4e067b[_0xc4ff('0xc')]);WhatsappInteractionEvents[_0xc4ff('0xd')](_0x59f848+':'+_0x2fac81['id'],_0x2fac81);WhatsappInteractionEvents[_0xc4ff('0xd')](_0x59f848,_0x2fac81);_0x49ec55(null);})['catch'](_0x49ec55(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module[_0xc4ff('0xe')]=WhatsappInteractionEvents;