1 // *************************************************************************
3 // * xCALLY Motion - The Omnichannel Contact Center *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved *
6 // *************************************************************************
8 // * Email: info@xcally.com *
9 // * Website: https://www.xcally.com *
11 // *************************************************************************
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. *
17 // *************************************************************************
18 var _0xbb45=['update','getUsers','Users','setDataValue','unreadMessages','length','emit','catch','hasOwnProperty','hook','events','../../mysqldb','WhatsappInteraction','WhatsappMessage','setMaxListeners','save'];(function(_0x57fae3,_0x5b0a60){var _0x439a3d=function(_0x2e8acb){while(--_0x2e8acb){_0x57fae3['push'](_0x57fae3['shift']());}};_0x439a3d(++_0x5b0a60);}(_0xbb45,0x16a));var _0x5bb4=function(_0x1385de,_0x4111c0){_0x1385de=_0x1385de-0x0;var _0x1c2e28=_0xbb45[_0x1385de];return _0x1c2e28;};'use strict';var EventEmitter=require(_0x5bb4('0x0'));var WhatsappInteraction=require(_0x5bb4('0x1'))['db'][_0x5bb4('0x2')];var WhatsappMessage=require(_0x5bb4('0x1'))['db'][_0x5bb4('0x3')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0x5bb4('0x4')](0x0);var events={'afterCreate':_0x5bb4('0x5'),'afterUpdate':_0x5bb4('0x6'),'afterDestroy':'remove'};function emitEvent(_0xf01da0){return function(_0x69faf5,_0x3dafec,_0x32b766){_0x69faf5[_0x5bb4('0x7')]({'attributes':['id'],'raw':!![]})['then'](function(_0x7fd39c){_0x69faf5['setDataValue'](_0x5bb4('0x8'),_0x7fd39c['map'](function(_0x5aceed){return{'id':_0x5aceed['id']};}));return WhatsappMessage['findAll']({'where':{'WhatsappInteractionId':_0x69faf5['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x180cc9){_0x69faf5[_0x5bb4('0x9')](_0x5bb4('0xa'),_0x180cc9[_0x5bb4('0xb')]);WhatsappInteractionEvents[_0x5bb4('0xc')](_0xf01da0+':'+_0x69faf5['id'],_0x69faf5);WhatsappInteractionEvents[_0x5bb4('0xc')](_0xf01da0,_0x69faf5);_0x32b766(null);})[_0x5bb4('0xd')](_0x32b766(null));};}for(var e in events){if(events[_0x5bb4('0xe')](e)){var event=events[e];WhatsappInteraction[_0x5bb4('0xf')](e,emitEvent(event));}}module['exports']=WhatsappInteractionEvents;