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 _0x5c6f=['map','findAll','length','emit','hasOwnProperty','hook','exports','events','../../mysqldb','FaxInteraction','FaxMessage','setMaxListeners','save','update','remove','getUsers','then','setDataValue'];(function(_0x102f0a,_0x13474d){var _0x35e503=function(_0x104b81){while(--_0x104b81){_0x102f0a['push'](_0x102f0a['shift']());}};_0x35e503(++_0x13474d);}(_0x5c6f,0x1c9));var _0xf5c6=function(_0xba6409,_0x2a3ae8){_0xba6409=_0xba6409-0x0;var _0x33e8f4=_0x5c6f[_0xba6409];return _0x33e8f4;};'use strict';var EventEmitter=require(_0xf5c6('0x0'));var FaxInteraction=require(_0xf5c6('0x1'))['db'][_0xf5c6('0x2')];var FaxMessage=require(_0xf5c6('0x1'))['db'][_0xf5c6('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xf5c6('0x4')](0x0);var events={'afterCreate':_0xf5c6('0x5'),'afterUpdate':_0xf5c6('0x6'),'afterDestroy':_0xf5c6('0x7')};function emitEvent(_0x4a72e6){return function(_0xe8d217,_0x1c7885,_0x4cf3bd){_0xe8d217[_0xf5c6('0x8')]({'attributes':['id'],'raw':!![]})[_0xf5c6('0x9')](function(_0x3438b1){_0xe8d217[_0xf5c6('0xa')]('Users',_0x3438b1[_0xf5c6('0xb')](function(_0x9b1f23){return{'id':_0x9b1f23['id']};}));return FaxMessage[_0xf5c6('0xc')]({'where':{'FaxInteractionId':_0xe8d217['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf5c6('0x9')](function(_0x1b1148){_0xe8d217[_0xf5c6('0xa')]('unreadMessages',_0x1b1148[_0xf5c6('0xd')]);FaxInteractionEvents[_0xf5c6('0xe')](_0x4a72e6+':'+_0xe8d217['id'],_0xe8d217);FaxInteractionEvents[_0xf5c6('0xe')](_0x4a72e6,_0xe8d217);_0x4cf3bd(null);})['catch'](_0x4cf3bd(null));};}for(var e in events){if(events[_0xf5c6('0xf')](e)){var event=events[e];FaxInteraction[_0xf5c6('0x10')](e,emitEvent(event));}}module[_0xf5c6('0x11')]=FaxInteractionEvents;