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 _0xfc76=['exports','../../mysqldb','SmsInteraction','SmsMessage','setMaxListeners','update','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hook'];(function(_0x5c4f6b,_0x2cdfce){var _0x104c4e=function(_0x31171b){while(--_0x31171b){_0x5c4f6b['push'](_0x5c4f6b['shift']());}};_0x104c4e(++_0x2cdfce);}(_0xfc76,0xb5));var _0x6fc7=function(_0x398997,_0x55e066){_0x398997=_0x398997-0x0;var _0x498e22=_0xfc76[_0x398997];return _0x498e22;};'use strict';var EventEmitter=require('events');var SmsInteraction=require(_0x6fc7('0x0'))['db'][_0x6fc7('0x1')];var SmsMessage=require(_0x6fc7('0x0'))['db'][_0x6fc7('0x2')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x6fc7('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x6fc7('0x4'),'afterDestroy':_0x6fc7('0x5')};function emitEvent(_0x51280c){return function(_0x13f682,_0x51cb40,_0xe8177b){_0x13f682[_0x6fc7('0x6')]({'attributes':['id'],'raw':!![]})[_0x6fc7('0x7')](function(_0x4da7c3){_0x13f682[_0x6fc7('0x8')](_0x6fc7('0x9'),_0x4da7c3[_0x6fc7('0xa')](function(_0x1d4fee){return{'id':_0x1d4fee['id']};}));return SmsMessage[_0x6fc7('0xb')]({'where':{'SmsInteractionId':_0x13f682['id'],'direction':'in','read':![]},'raw':!![]});})[_0x6fc7('0x7')](function(_0x4de75e){_0x13f682[_0x6fc7('0x8')](_0x6fc7('0xc'),_0x4de75e[_0x6fc7('0xd')]);SmsInteractionEvents[_0x6fc7('0xe')](_0x51280c+':'+_0x13f682['id'],_0x13f682);SmsInteractionEvents[_0x6fc7('0xe')](_0x51280c,_0x13f682);_0xe8177b(null);})[_0x6fc7('0xf')](_0xe8177b(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];SmsInteraction[_0x6fc7('0x10')](e,emitEvent(event));}}module[_0x6fc7('0x11')]=SmsInteractionEvents;