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 _0xd824=['SmsMessage','setMaxListeners','save','update','remove','setDataValue','Users','unreadMessages','emit','catch','hasOwnProperty','hook','events','../../mysqldb'];(function(_0x12b683,_0x124186){var _0xfb150b=function(_0x565ce7){while(--_0x565ce7){_0x12b683['push'](_0x12b683['shift']());}};_0xfb150b(++_0x124186);}(_0xd824,0xc2));var _0x4d82=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0xd824[_0x19950b];return _0x3c6b41;};'use strict';var EventEmitter=require(_0x4d82('0x0'));var SmsInteraction=require(_0x4d82('0x1'))['db']['SmsInteraction'];var SmsMessage=require('../../mysqldb')['db'][_0x4d82('0x2')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x4d82('0x3')](0x0);var events={'afterCreate':_0x4d82('0x4'),'afterUpdate':_0x4d82('0x5'),'afterDestroy':_0x4d82('0x6')};function emitEvent(_0x1c8ad9){return function(_0x4bc746,_0x57850a,_0xd00023){_0x4bc746['getUsers']({'attributes':['id'],'raw':!![]})['then'](function(_0x464caf){_0x4bc746[_0x4d82('0x7')](_0x4d82('0x8'),_0x464caf['map'](function(_0x1ff96b){return{'id':_0x1ff96b['id']};}));return SmsMessage['findAll']({'where':{'SmsInteractionId':_0x4bc746['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x580bbd){_0x4bc746[_0x4d82('0x7')](_0x4d82('0x9'),_0x580bbd['length']);SmsInteractionEvents[_0x4d82('0xa')](_0x1c8ad9+':'+_0x4bc746['id'],_0x4bc746);SmsInteractionEvents['emit'](_0x1c8ad9,_0x4bc746);_0xd00023(null);})[_0x4d82('0xb')](_0xd00023(null));};}for(var e in events){if(events[_0x4d82('0xc')](e)){var event=events[e];SmsInteraction[_0x4d82('0xd')](e,emitEvent(event));}}module['exports']=SmsInteractionEvents;