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 _0xf694=['getUsers','then','setDataValue','map','findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','setMaxListeners','save','update','remove'];(function(_0x95de0a,_0x48cbbe){var _0x1756ac=function(_0x14c192){while(--_0x14c192){_0x95de0a['push'](_0x95de0a['shift']());}};_0x1756ac(++_0x48cbbe);}(_0xf694,0x162));var _0x4f69=function(_0x33e4af,_0x40e275){_0x33e4af=_0x33e4af-0x0;var _0x22f0ac=_0xf694[_0x33e4af];return _0x22f0ac;};'use strict';var EventEmitter=require(_0x4f69('0x0'));var FaxInteraction=require(_0x4f69('0x1'))['db']['FaxInteraction'];var FaxMessage=require(_0x4f69('0x1'))['db']['FaxMessage'];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x4f69('0x2')](0x0);var events={'afterCreate':_0x4f69('0x3'),'afterUpdate':_0x4f69('0x4'),'afterDestroy':_0x4f69('0x5')};function emitEvent(_0x352229){return function(_0x25cc4c,_0x187986,_0x559aa8){_0x25cc4c[_0x4f69('0x6')]({'attributes':['id'],'raw':!![]})[_0x4f69('0x7')](function(_0xde67b0){_0x25cc4c[_0x4f69('0x8')]('Users',_0xde67b0[_0x4f69('0x9')](function(_0x4d8469){return{'id':_0x4d8469['id']};}));return FaxMessage[_0x4f69('0xa')]({'where':{'FaxInteractionId':_0x25cc4c['id'],'direction':'in','read':![]},'raw':!![]});})[_0x4f69('0x7')](function(_0x458bf5){_0x25cc4c[_0x4f69('0x8')](_0x4f69('0xb'),_0x458bf5[_0x4f69('0xc')]);FaxInteractionEvents[_0x4f69('0xd')](_0x352229+':'+_0x25cc4c['id'],_0x25cc4c);FaxInteractionEvents[_0x4f69('0xd')](_0x352229,_0x25cc4c);_0x559aa8(null);})[_0x4f69('0xe')](_0x559aa8(null));};}for(var e in events){if(events[_0x4f69('0xf')](e)){var event=events[e];FaxInteraction[_0x4f69('0x10')](e,emitEvent(event));}}module[_0x4f69('0x11')]=FaxInteractionEvents;