f885e148b2de903a37c6fab65d75c9aa1219ab5b
[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 _0x23e2=['save','remove','setDataValue','Users','findAll','then','unreadMessages','length','emit','hook','events','../../mysqldb','FaxInteraction','FaxMessage','setMaxListeners'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x23e2,0xcd));var _0x223e=function(_0x1b6c0c,_0x51ef20){_0x1b6c0c=_0x1b6c0c-0x0;var _0x178991=_0x23e2[_0x1b6c0c];return _0x178991;};'use strict';var EventEmitter=require(_0x223e('0x0'));var FaxInteraction=require(_0x223e('0x1'))['db'][_0x223e('0x2')];var FaxMessage=require(_0x223e('0x1'))['db'][_0x223e('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x223e('0x4')](0x0);var events={'afterCreate':_0x223e('0x5'),'afterUpdate':'update','afterDestroy':_0x223e('0x6')};function emitEvent(_0xb31347){return function(_0x2ed1e2,_0x115c67,_0x2a285a){_0x2ed1e2['getUsers']({'attributes':['id'],'raw':!![]})['then'](function(_0x4ef318){_0x2ed1e2[_0x223e('0x7')](_0x223e('0x8'),_0x4ef318['map'](function(_0x6ad24d){return{'id':_0x6ad24d['id']};}));return FaxMessage[_0x223e('0x9')]({'where':{'FaxInteractionId':_0x2ed1e2['id'],'direction':'in','read':![]},'raw':!![]});})[_0x223e('0xa')](function(_0x3ff153){_0x2ed1e2[_0x223e('0x7')](_0x223e('0xb'),_0x3ff153[_0x223e('0xc')]);FaxInteractionEvents[_0x223e('0xd')](_0xb31347+':'+_0x2ed1e2['id'],_0x2ed1e2);FaxInteractionEvents[_0x223e('0xd')](_0xb31347,_0x2ed1e2);_0x2a285a(null);})['catch'](_0x2a285a(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];FaxInteraction[_0x223e('0xe')](e,emitEvent(event));}}module['exports']=FaxInteractionEvents;