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 _0x6f86=['then','emit','catch','hook','exports','events','../../mysqldb','FaxInteraction','setMaxListeners','save','update','remove','getUsers','setDataValue','Users','map'];(function(_0x4d666a,_0x1ed918){var _0x4fcc6b=function(_0x4fcdef){while(--_0x4fcdef){_0x4d666a['push'](_0x4d666a['shift']());}};_0x4fcc6b(++_0x1ed918);}(_0x6f86,0x105));var _0x66f8=function(_0x17ff72,_0x5a05c9){_0x17ff72=_0x17ff72-0x0;var _0x4b987c=_0x6f86[_0x17ff72];return _0x4b987c;};'use strict';var EventEmitter=require(_0x66f8('0x0'));var FaxInteraction=require(_0x66f8('0x1'))['db'][_0x66f8('0x2')];var FaxMessage=require('../../mysqldb')['db']['FaxMessage'];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x66f8('0x3')](0x0);var events={'afterCreate':_0x66f8('0x4'),'afterUpdate':_0x66f8('0x5'),'afterDestroy':_0x66f8('0x6')};function emitEvent(_0x2a24ac){return function(_0x18f941,_0x1b299b,_0x5dc237){_0x18f941[_0x66f8('0x7')]({'attributes':['id'],'raw':!![]})['then'](function(_0x1bf770){_0x18f941[_0x66f8('0x8')](_0x66f8('0x9'),_0x1bf770[_0x66f8('0xa')](function(_0x14a220){return{'id':_0x14a220['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0x18f941['id'],'direction':'in','read':![]},'raw':!![]});})[_0x66f8('0xb')](function(_0x1f8424){_0x18f941[_0x66f8('0x8')]('unreadMessages',_0x1f8424['length']);FaxInteractionEvents[_0x66f8('0xc')](_0x2a24ac+':'+_0x18f941['id'],_0x18f941);FaxInteractionEvents[_0x66f8('0xc')](_0x2a24ac,_0x18f941);_0x5dc237(null);})[_0x66f8('0xd')](_0x5dc237(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];FaxInteraction[_0x66f8('0xe')](e,emitEvent(event));}}module[_0x66f8('0xf')]=FaxInteractionEvents;