3c8f361be239873ea0f4463ce84cc6b600ed6daf
[motion2.git] / server / api / faxInteraction / faxInteraction.events.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
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.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xff83=['../../mysqldb','FaxInteraction','FaxMessage','setMaxListeners','save','update','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events'];(function(_0x427352,_0x1bce61){var _0x23e0e6=function(_0x2a42a9){while(--_0x2a42a9){_0x427352['push'](_0x427352['shift']());}};_0x23e0e6(++_0x1bce61);}(_0xff83,0x167));var _0x3ff8=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0xff83[_0x19e35c];return _0x3e1fe8;};'use strict';var EventEmitter=require(_0x3ff8('0x0'));var FaxInteraction=require(_0x3ff8('0x1'))['db'][_0x3ff8('0x2')];var FaxMessage=require(_0x3ff8('0x1'))['db'][_0x3ff8('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x3ff8('0x4')](0x0);var events={'afterCreate':_0x3ff8('0x5'),'afterUpdate':_0x3ff8('0x6'),'afterDestroy':'remove'};function emitEvent(_0x23a5ca){return function(_0x247bfb,_0x206ad6,_0x27a2d1){_0x247bfb[_0x3ff8('0x7')]({'attributes':['id'],'raw':!![]})[_0x3ff8('0x8')](function(_0x526daf){_0x247bfb[_0x3ff8('0x9')](_0x3ff8('0xa'),_0x526daf[_0x3ff8('0xb')](function(_0x5e6afb){return{'id':_0x5e6afb['id']};}));return FaxMessage[_0x3ff8('0xc')]({'where':{'FaxInteractionId':_0x247bfb['id'],'direction':'in','read':![]},'raw':!![]});})[_0x3ff8('0x8')](function(_0x52ac7c){_0x247bfb[_0x3ff8('0x9')](_0x3ff8('0xd'),_0x52ac7c[_0x3ff8('0xe')]);FaxInteractionEvents[_0x3ff8('0xf')](_0x23a5ca+':'+_0x247bfb['id'],_0x247bfb);FaxInteractionEvents['emit'](_0x23a5ca,_0x247bfb);_0x27a2d1(null);})[_0x3ff8('0x10')](_0x27a2d1(null));};}for(var e in events){if(events[_0x3ff8('0x11')](e)){var event=events[e];FaxInteraction[_0x3ff8('0x12')](e,emitEvent(event));}}module[_0x3ff8('0x13')]=FaxInteractionEvents;