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 _0x062d=['map','setDataValue','unreadMessages','emit','catch','hasOwnProperty','hook','events','../../mysqldb','FaxInteraction','save','update','remove','getUsers','then','Users'];(function(_0x37bcd8,_0x27bed9){var _0x422480=function(_0x510db3){while(--_0x510db3){_0x37bcd8['push'](_0x37bcd8['shift']());}};_0x422480(++_0x27bed9);}(_0x062d,0x1d7));var _0xd062=function(_0x5401ae,_0x5e58ac){_0x5401ae=_0x5401ae-0x0;var _0x286068=_0x062d[_0x5401ae];return _0x286068;};'use strict';var EventEmitter=require(_0xd062('0x0'));var FaxInteraction=require(_0xd062('0x1'))['db'][_0xd062('0x2')];var FaxMessage=require(_0xd062('0x1'))['db']['FaxMessage'];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xd062('0x3'),'afterUpdate':_0xd062('0x4'),'afterDestroy':_0xd062('0x5')};function emitEvent(_0x1439c7){return function(_0xda1dc,_0x173051,_0x2d9f39){_0xda1dc[_0xd062('0x6')]({'attributes':['id'],'raw':!![]})[_0xd062('0x7')](function(_0x4562fa){_0xda1dc['setDataValue'](_0xd062('0x8'),_0x4562fa[_0xd062('0x9')](function(_0x4f46f6){return{'id':_0x4f46f6['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0xda1dc['id'],'direction':'in','read':![]},'raw':!![]});})[_0xd062('0x7')](function(_0x4e75bc){_0xda1dc[_0xd062('0xa')](_0xd062('0xb'),_0x4e75bc['length']);FaxInteractionEvents[_0xd062('0xc')](_0x1439c7+':'+_0xda1dc['id'],_0xda1dc);FaxInteractionEvents[_0xd062('0xc')](_0x1439c7,_0xda1dc);_0x2d9f39(null);})[_0xd062('0xd')](_0x2d9f39(null));};}for(var e in events){if(events[_0xd062('0xe')](e)){var event=events[e];FaxInteraction[_0xd062('0xf')](e,emitEvent(event));}}module['exports']=FaxInteractionEvents;