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 _0xdfaf=['then','Users','map','setDataValue','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','../../mysqldb','FaxMessage','setMaxListeners','save','update','getUsers'];(function(_0x14af1b,_0x25cff8){var _0x4acefb=function(_0x327bcf){while(--_0x327bcf){_0x14af1b['push'](_0x14af1b['shift']());}};_0x4acefb(++_0x25cff8);}(_0xdfaf,0x13d));var _0xfdfa=function(_0xbef9cf,_0x554612){_0xbef9cf=_0xbef9cf-0x0;var _0x44c9d3=_0xdfaf[_0xbef9cf];return _0x44c9d3;};'use strict';var EventEmitter=require('events');var FaxInteraction=require(_0xfdfa('0x0'))['db']['FaxInteraction'];var FaxMessage=require(_0xfdfa('0x0'))['db'][_0xfdfa('0x1')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xfdfa('0x2')](0x0);var events={'afterCreate':_0xfdfa('0x3'),'afterUpdate':_0xfdfa('0x4'),'afterDestroy':'remove'};function emitEvent(_0x1cf142){return function(_0x5092b4,_0x393ef7,_0x57785a){_0x5092b4[_0xfdfa('0x5')]({'attributes':['id'],'raw':!![]})[_0xfdfa('0x6')](function(_0x464aa0){_0x5092b4['setDataValue'](_0xfdfa('0x7'),_0x464aa0[_0xfdfa('0x8')](function(_0x1a8740){return{'id':_0x1a8740['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0x5092b4['id'],'direction':'in','read':![]},'raw':!![]});})[_0xfdfa('0x6')](function(_0xeb13fb){_0x5092b4[_0xfdfa('0x9')](_0xfdfa('0xa'),_0xeb13fb[_0xfdfa('0xb')]);FaxInteractionEvents[_0xfdfa('0xc')](_0x1cf142+':'+_0x5092b4['id'],_0x5092b4);FaxInteractionEvents[_0xfdfa('0xc')](_0x1cf142,_0x5092b4);_0x57785a(null);})[_0xfdfa('0xd')](_0x57785a(null));};}for(var e in events){if(events[_0xfdfa('0xe')](e)){var event=events[e];FaxInteraction[_0xfdfa('0xf')](e,emitEvent(event));}}module[_0xfdfa('0x10')]=FaxInteractionEvents;