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 _0xf93a=['remove','getUsers','then','setDataValue','Users','findAll','emit','catch','hasOwnProperty','events','../../mysqldb','OpenchannelInteraction','OpenchannelMessage','setMaxListeners','save','update'];(function(_0x16a637,_0x5eb627){var _0x25126d=function(_0x54e016){while(--_0x54e016){_0x16a637['push'](_0x16a637['shift']());}};_0x25126d(++_0x5eb627);}(_0xf93a,0x69));var _0xaf93=function(_0x1436c3,_0x405b2f){_0x1436c3=_0x1436c3-0x0;var _0x49f2a4=_0xf93a[_0x1436c3];return _0x49f2a4;};'use strict';var EventEmitter=require(_0xaf93('0x0'));var OpenchannelInteraction=require(_0xaf93('0x1'))['db'][_0xaf93('0x2')];var OpenchannelMessage=require(_0xaf93('0x1'))['db'][_0xaf93('0x3')];var OpenchannelInteractionEvents=new EventEmitter();OpenchannelInteractionEvents[_0xaf93('0x4')](0x0);var events={'afterCreate':_0xaf93('0x5'),'afterUpdate':_0xaf93('0x6'),'afterDestroy':_0xaf93('0x7')};function emitEvent(_0x12acfd){return function(_0x56db76,_0x2cd327,_0x4ab1c5){_0x56db76[_0xaf93('0x8')]({'attributes':['id'],'raw':!![]})[_0xaf93('0x9')](function(_0x457ff0){_0x56db76[_0xaf93('0xa')](_0xaf93('0xb'),_0x457ff0['map'](function(_0x1cacbd){return{'id':_0x1cacbd['id']};}));return OpenchannelMessage[_0xaf93('0xc')]({'where':{'OpenchannelInteractionId':_0x56db76['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x2c246c){_0x56db76[_0xaf93('0xa')]('unreadMessages',_0x2c246c['length']);OpenchannelInteractionEvents[_0xaf93('0xd')](_0x12acfd+':'+_0x56db76['id'],_0x56db76);OpenchannelInteractionEvents[_0xaf93('0xd')](_0x12acfd,_0x56db76);_0x4ab1c5(null);})[_0xaf93('0xe')](_0x4ab1c5(null));};}for(var e in events){if(events[_0xaf93('0xf')](e)){var event=events[e];OpenchannelInteraction['hook'](e,emitEvent(event));}}module['exports']=OpenchannelInteractionEvents;