Built motion from commit dc14b02d.|2.6.27
[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 _0x6f80=['catch','hasOwnProperty','exports','events','FaxInteraction','../../mysqldb','FaxMessage','setMaxListeners','save','remove','getUsers','then','setDataValue','Users','findAll','unreadMessages','length'];(function(_0x4e76d8,_0x85e650){var _0x340fb6=function(_0x33118e){while(--_0x33118e){_0x4e76d8['push'](_0x4e76d8['shift']());}};_0x340fb6(++_0x85e650);}(_0x6f80,0x7a));var _0x06f8=function(_0x1b5639,_0x2475dc){_0x1b5639=_0x1b5639-0x0;var _0x3f6bcf=_0x6f80[_0x1b5639];return _0x3f6bcf;};'use strict';var EventEmitter=require(_0x06f8('0x0'));var FaxInteraction=require('../../mysqldb')['db'][_0x06f8('0x1')];var FaxMessage=require(_0x06f8('0x2'))['db'][_0x06f8('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x06f8('0x4')](0x0);var events={'afterCreate':_0x06f8('0x5'),'afterUpdate':'update','afterDestroy':_0x06f8('0x6')};function emitEvent(_0x390711){return function(_0x5c0466,_0x56c7d9,_0x299e20){_0x5c0466[_0x06f8('0x7')]({'attributes':['id'],'raw':!![]})[_0x06f8('0x8')](function(_0x48b4f7){_0x5c0466[_0x06f8('0x9')](_0x06f8('0xa'),_0x48b4f7['map'](function(_0x406c20){return{'id':_0x406c20['id']};}));return FaxMessage[_0x06f8('0xb')]({'where':{'FaxInteractionId':_0x5c0466['id'],'direction':'in','read':![]},'raw':!![]});})[_0x06f8('0x8')](function(_0x1a8ff2){_0x5c0466['setDataValue'](_0x06f8('0xc'),_0x1a8ff2[_0x06f8('0xd')]);FaxInteractionEvents['emit'](_0x390711+':'+_0x5c0466['id'],_0x5c0466);FaxInteractionEvents['emit'](_0x390711,_0x5c0466);_0x299e20(null);})[_0x06f8('0xe')](_0x299e20(null));};}for(var e in events){if(events[_0x06f8('0xf')](e)){var event=events[e];FaxInteraction['hook'](e,emitEvent(event));}}module[_0x06f8('0x10')]=FaxInteractionEvents;