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 _0xa6ff=['WhatsappMessage','setMaxListeners','save','remove','then','setDataValue','Users','findAll','unreadMessages','emit','catch','hasOwnProperty','exports','events','../../mysqldb','WhatsappInteraction'];(function(_0x432682,_0x253044){var _0x463d05=function(_0xa73403){while(--_0xa73403){_0x432682['push'](_0x432682['shift']());}};_0x463d05(++_0x253044);}(_0xa6ff,0x8d));var _0xfa6f=function(_0x1cc372,_0x79999){_0x1cc372=_0x1cc372-0x0;var _0x1c8203=_0xa6ff[_0x1cc372];return _0x1c8203;};'use strict';var EventEmitter=require(_0xfa6f('0x0'));var WhatsappInteraction=require(_0xfa6f('0x1'))['db'][_0xfa6f('0x2')];var WhatsappMessage=require(_0xfa6f('0x1'))['db'][_0xfa6f('0x3')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xfa6f('0x4')](0x0);var events={'afterCreate':_0xfa6f('0x5'),'afterUpdate':'update','afterDestroy':_0xfa6f('0x6')};function emitEvent(_0x62f0bd){return function(_0x35598e,_0x56c159,_0x288524){_0x35598e['getUsers']({'attributes':['id'],'raw':!![]})[_0xfa6f('0x7')](function(_0x81ddef){_0x35598e[_0xfa6f('0x8')](_0xfa6f('0x9'),_0x81ddef['map'](function(_0x5f233d){return{'id':_0x5f233d['id']};}));return WhatsappMessage[_0xfa6f('0xa')]({'where':{'WhatsappInteractionId':_0x35598e['id'],'direction':'in','read':![]},'raw':!![]});})[_0xfa6f('0x7')](function(_0x5a960c){_0x35598e[_0xfa6f('0x8')](_0xfa6f('0xb'),_0x5a960c['length']);WhatsappInteractionEvents['emit'](_0x62f0bd+':'+_0x35598e['id'],_0x35598e);WhatsappInteractionEvents[_0xfa6f('0xc')](_0x62f0bd,_0x35598e);_0x288524(null);})[_0xfa6f('0xd')](_0x288524(null));};}for(var e in events){if(events[_0xfa6f('0xe')](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module[_0xfa6f('0xf')]=WhatsappInteractionEvents;