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 _0x515d=['unreadMessages','emit','catch','hasOwnProperty','exports','../../mysqldb','WhatsappInteraction','WhatsappMessage','setMaxListeners','save','update','remove','getUsers','then','setDataValue','Users','findAll'];(function(_0x1b0640,_0x30b23d){var _0x4aa1ec=function(_0x59fbc8){while(--_0x59fbc8){_0x1b0640['push'](_0x1b0640['shift']());}};_0x4aa1ec(++_0x30b23d);}(_0x515d,0x104));var _0xd515=function(_0x535f1d,_0x259e98){_0x535f1d=_0x535f1d-0x0;var _0x3f4076=_0x515d[_0x535f1d];return _0x3f4076;};'use strict';var EventEmitter=require('events');var WhatsappInteraction=require(_0xd515('0x0'))['db'][_0xd515('0x1')];var WhatsappMessage=require(_0xd515('0x0'))['db'][_0xd515('0x2')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xd515('0x3')](0x0);var events={'afterCreate':_0xd515('0x4'),'afterUpdate':_0xd515('0x5'),'afterDestroy':_0xd515('0x6')};function emitEvent(_0x51e08b){return function(_0x1bd639,_0x544f53,_0x4d578b){_0x1bd639[_0xd515('0x7')]({'attributes':['id'],'raw':!![]})[_0xd515('0x8')](function(_0x43d633){_0x1bd639[_0xd515('0x9')](_0xd515('0xa'),_0x43d633['map'](function(_0x31d6b6){return{'id':_0x31d6b6['id']};}));return WhatsappMessage[_0xd515('0xb')]({'where':{'WhatsappInteractionId':_0x1bd639['id'],'direction':'in','read':![]},'raw':!![]});})[_0xd515('0x8')](function(_0x423156){_0x1bd639[_0xd515('0x9')](_0xd515('0xc'),_0x423156['length']);WhatsappInteractionEvents[_0xd515('0xd')](_0x51e08b+':'+_0x1bd639['id'],_0x1bd639);WhatsappInteractionEvents[_0xd515('0xd')](_0x51e08b,_0x1bd639);_0x4d578b(null);})[_0xd515('0xe')](_0x4d578b(null));};}for(var e in events){if(events[_0xd515('0xf')](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module[_0xd515('0x10')]=WhatsappInteractionEvents;