Built motion from commit (unavailable).|2.5.14
[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 _0x326f=['../../mysqldb','FaxMessage','setMaxListeners','save','update','remove','then','setDataValue','Users','unreadMessages','length','emit','hasOwnProperty','exports','events'];(function(_0x4eeb9a,_0x1d4396){var _0x51055b=function(_0x5bad60){while(--_0x5bad60){_0x4eeb9a['push'](_0x4eeb9a['shift']());}};_0x51055b(++_0x1d4396);}(_0x326f,0xd1));var _0xf326=function(_0x3f7121,_0x510a56){_0x3f7121=_0x3f7121-0x0;var _0x4c7194=_0x326f[_0x3f7121];return _0x4c7194;};'use strict';var EventEmitter=require(_0xf326('0x0'));var FaxInteraction=require('../../mysqldb')['db']['FaxInteraction'];var FaxMessage=require(_0xf326('0x1'))['db'][_0xf326('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xf326('0x3')](0x0);var events={'afterCreate':_0xf326('0x4'),'afterUpdate':_0xf326('0x5'),'afterDestroy':_0xf326('0x6')};function emitEvent(_0x9445c6){return function(_0xf1c243,_0x1b5a56,_0x3ace29){_0xf1c243['getUsers']({'attributes':['id'],'raw':!![]})[_0xf326('0x7')](function(_0x3851eb){_0xf1c243[_0xf326('0x8')](_0xf326('0x9'),_0x3851eb['map'](function(_0x4c206c){return{'id':_0x4c206c['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0xf1c243['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf326('0x7')](function(_0x1fc80e){_0xf1c243[_0xf326('0x8')](_0xf326('0xa'),_0x1fc80e[_0xf326('0xb')]);FaxInteractionEvents['emit'](_0x9445c6+':'+_0xf1c243['id'],_0xf1c243);FaxInteractionEvents[_0xf326('0xc')](_0x9445c6,_0xf1c243);_0x3ace29(null);})['catch'](_0x3ace29(null));};}for(var e in events){if(events[_0xf326('0xd')](e)){var event=events[e];FaxInteraction['hook'](e,emitEvent(event));}}module[_0xf326('0xe')]=FaxInteractionEvents;