Built motion from commit d1eab355.|2.6.28
[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 _0xb28e=['update','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','hasOwnProperty','exports','events','FaxInteraction','../../mysqldb','FaxMessage','setMaxListeners'];(function(_0x29ff78,_0xc9f226){var _0x5001f3=function(_0x22872b){while(--_0x22872b){_0x29ff78['push'](_0x29ff78['shift']());}};_0x5001f3(++_0xc9f226);}(_0xb28e,0xaf));var _0xeb28=function(_0x4fa1df,_0x3c37a4){_0x4fa1df=_0x4fa1df-0x0;var _0x2e9a49=_0xb28e[_0x4fa1df];return _0x2e9a49;};'use strict';var EventEmitter=require(_0xeb28('0x0'));var FaxInteraction=require('../../mysqldb')['db'][_0xeb28('0x1')];var FaxMessage=require(_0xeb28('0x2'))['db'][_0xeb28('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xeb28('0x4')](0x0);var events={'afterCreate':'save','afterUpdate':_0xeb28('0x5'),'afterDestroy':_0xeb28('0x6')};function emitEvent(_0x3a11c1){return function(_0x592891,_0x59de3c,_0x2ff449){_0x592891[_0xeb28('0x7')]({'attributes':['id'],'raw':!![]})[_0xeb28('0x8')](function(_0x448685){_0x592891[_0xeb28('0x9')](_0xeb28('0xa'),_0x448685[_0xeb28('0xb')](function(_0x421302){return{'id':_0x421302['id']};}));return FaxMessage[_0xeb28('0xc')]({'where':{'FaxInteractionId':_0x592891['id'],'direction':'in','read':![]},'raw':!![]});})[_0xeb28('0x8')](function(_0x5922a1){_0x592891[_0xeb28('0x9')](_0xeb28('0xd'),_0x5922a1[_0xeb28('0xe')]);FaxInteractionEvents[_0xeb28('0xf')](_0x3a11c1+':'+_0x592891['id'],_0x592891);FaxInteractionEvents['emit'](_0x3a11c1,_0x592891);_0x2ff449(null);})['catch'](_0x2ff449(null));};}for(var e in events){if(events[_0xeb28('0x10')](e)){var event=events[e];FaxInteraction['hook'](e,emitEvent(event));}}module[_0xeb28('0x11')]=FaxInteractionEvents;