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 _0x2e7f=['Users','map','findAll','then','setDataValue','unreadMessages','length','emit','catch','hasOwnProperty','exports','events','../../mysqldb','save','remove','getUsers'];(function(_0x35fbcb,_0x558ab2){var _0x40e9ff=function(_0x1c6c93){while(--_0x1c6c93){_0x35fbcb['push'](_0x35fbcb['shift']());}};_0x40e9ff(++_0x558ab2);}(_0x2e7f,0x14b));var _0xf2e7=function(_0x1683eb,_0x134858){_0x1683eb=_0x1683eb-0x0;var _0x27f2af=_0x2e7f[_0x1683eb];return _0x27f2af;};'use strict';var EventEmitter=require(_0xf2e7('0x0'));var WhatsappInteraction=require(_0xf2e7('0x1'))['db']['WhatsappInteraction'];var WhatsappMessage=require(_0xf2e7('0x1'))['db']['WhatsappMessage'];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xf2e7('0x2'),'afterUpdate':'update','afterDestroy':_0xf2e7('0x3')};function emitEvent(_0x1a2bef){return function(_0x50fa13,_0x1cebad,_0x43bcae){_0x50fa13[_0xf2e7('0x4')]({'attributes':['id'],'raw':!![]})['then'](function(_0x95ef3d){_0x50fa13['setDataValue'](_0xf2e7('0x5'),_0x95ef3d[_0xf2e7('0x6')](function(_0x12e30c){return{'id':_0x12e30c['id']};}));return WhatsappMessage[_0xf2e7('0x7')]({'where':{'WhatsappInteractionId':_0x50fa13['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf2e7('0x8')](function(_0x3a1620){_0x50fa13[_0xf2e7('0x9')](_0xf2e7('0xa'),_0x3a1620[_0xf2e7('0xb')]);WhatsappInteractionEvents[_0xf2e7('0xc')](_0x1a2bef+':'+_0x50fa13['id'],_0x50fa13);WhatsappInteractionEvents[_0xf2e7('0xc')](_0x1a2bef,_0x50fa13);_0x43bcae(null);})[_0xf2e7('0xd')](_0x43bcae(null));};}for(var e in events){if(events[_0xf2e7('0xe')](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module[_0xf2e7('0xf')]=WhatsappInteractionEvents;