Built motion from commit 58b0471d.|2.6.29
[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 _0x2f39=['exports','events','../../mysqldb','FaxInteraction','FaxMessage','save','update','remove','then','setDataValue','findAll','unreadMessages','length','emit','catch','hook'];(function(_0x531722,_0x161aa9){var _0x3f1769=function(_0x44e0d8){while(--_0x44e0d8){_0x531722['push'](_0x531722['shift']());}};_0x3f1769(++_0x161aa9);}(_0x2f39,0x1b1));var _0x92f3=function(_0xef4cf0,_0x16c9c3){_0xef4cf0=_0xef4cf0-0x0;var _0x497ad2=_0x2f39[_0xef4cf0];return _0x497ad2;};'use strict';var EventEmitter=require(_0x92f3('0x0'));var FaxInteraction=require(_0x92f3('0x1'))['db'][_0x92f3('0x2')];var FaxMessage=require(_0x92f3('0x1'))['db'][_0x92f3('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x92f3('0x4'),'afterUpdate':_0x92f3('0x5'),'afterDestroy':_0x92f3('0x6')};function emitEvent(_0x44155a){return function(_0x1315cc,_0x541cdb,_0x2307b0){_0x1315cc['getUsers']({'attributes':['id'],'raw':!![]})[_0x92f3('0x7')](function(_0x4b5ff5){_0x1315cc[_0x92f3('0x8')]('Users',_0x4b5ff5['map'](function(_0x128a6b){return{'id':_0x128a6b['id']};}));return FaxMessage[_0x92f3('0x9')]({'where':{'FaxInteractionId':_0x1315cc['id'],'direction':'in','read':![]},'raw':!![]});})[_0x92f3('0x7')](function(_0x230f36){_0x1315cc[_0x92f3('0x8')](_0x92f3('0xa'),_0x230f36[_0x92f3('0xb')]);FaxInteractionEvents[_0x92f3('0xc')](_0x44155a+':'+_0x1315cc['id'],_0x1315cc);FaxInteractionEvents[_0x92f3('0xc')](_0x44155a,_0x1315cc);_0x2307b0(null);})[_0x92f3('0xd')](_0x2307b0(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];FaxInteraction[_0x92f3('0xe')](e,emitEvent(event));}}module[_0x92f3('0xf')]=FaxInteractionEvents;