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 _0x3f19=['emit','catch','hasOwnProperty','hook','exports','events','WhatsappMessage','save','update','remove','getUsers','then','setDataValue','map','findAll','unreadMessages','length'];(function(_0x22f725,_0x5b2f65){var _0x39ef4a=function(_0x51dc37){while(--_0x51dc37){_0x22f725['push'](_0x22f725['shift']());}};_0x39ef4a(++_0x5b2f65);}(_0x3f19,0xc0));var _0x93f1=function(_0x3e469e,_0x334923){_0x3e469e=_0x3e469e-0x0;var _0x33d855=_0x3f19[_0x3e469e];return _0x33d855;};'use strict';var EventEmitter=require(_0x93f1('0x0'));var WhatsappInteraction=require('../../mysqldb')['db']['WhatsappInteraction'];var WhatsappMessage=require('../../mysqldb')['db'][_0x93f1('0x1')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x93f1('0x2'),'afterUpdate':_0x93f1('0x3'),'afterDestroy':_0x93f1('0x4')};function emitEvent(_0x2057aa){return function(_0x5dbfbc,_0x1ca333,_0x522769){_0x5dbfbc[_0x93f1('0x5')]({'attributes':['id'],'raw':!![]})[_0x93f1('0x6')](function(_0x171bf6){_0x5dbfbc[_0x93f1('0x7')]('Users',_0x171bf6[_0x93f1('0x8')](function(_0xf3d309){return{'id':_0xf3d309['id']};}));return WhatsappMessage[_0x93f1('0x9')]({'where':{'WhatsappInteractionId':_0x5dbfbc['id'],'direction':'in','read':![]},'raw':!![]});})[_0x93f1('0x6')](function(_0xfe4f0){_0x5dbfbc['setDataValue'](_0x93f1('0xa'),_0xfe4f0[_0x93f1('0xb')]);WhatsappInteractionEvents[_0x93f1('0xc')](_0x2057aa+':'+_0x5dbfbc['id'],_0x5dbfbc);WhatsappInteractionEvents[_0x93f1('0xc')](_0x2057aa,_0x5dbfbc);_0x522769(null);})[_0x93f1('0xd')](_0x522769(null));};}for(var e in events){if(events[_0x93f1('0xe')](e)){var event=events[e];WhatsappInteraction[_0x93f1('0xf')](e,emitEvent(event));}}module[_0x93f1('0x10')]=WhatsappInteractionEvents;