Built motion from commit f3da74b7.|2.5.36
[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 _0x769f=['hook','exports','../../mysqldb','FaxInteraction','FaxMessage','update','remove','then','Users','map','findAll','setDataValue','unreadMessages','length','emit','catch','hasOwnProperty'];(function(_0x57d56c,_0x4dd016){var _0x5845ec=function(_0x162ff0){while(--_0x162ff0){_0x57d56c['push'](_0x57d56c['shift']());}};_0x5845ec(++_0x4dd016);}(_0x769f,0x19a));var _0xf769=function(_0x240069,_0x2f7ccc){_0x240069=_0x240069-0x0;var _0x1ff577=_0x769f[_0x240069];return _0x1ff577;};'use strict';var EventEmitter=require('events');var FaxInteraction=require(_0xf769('0x0'))['db'][_0xf769('0x1')];var FaxMessage=require(_0xf769('0x0'))['db'][_0xf769('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':_0xf769('0x3'),'afterDestroy':_0xf769('0x4')};function emitEvent(_0x515afc){return function(_0x442950,_0xd92cd2,_0x45c3cf){_0x442950['getUsers']({'attributes':['id'],'raw':!![]})[_0xf769('0x5')](function(_0x429677){_0x442950['setDataValue'](_0xf769('0x6'),_0x429677[_0xf769('0x7')](function(_0x36e29c){return{'id':_0x36e29c['id']};}));return FaxMessage[_0xf769('0x8')]({'where':{'FaxInteractionId':_0x442950['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf769('0x5')](function(_0x196335){_0x442950[_0xf769('0x9')](_0xf769('0xa'),_0x196335[_0xf769('0xb')]);FaxInteractionEvents['emit'](_0x515afc+':'+_0x442950['id'],_0x442950);FaxInteractionEvents[_0xf769('0xc')](_0x515afc,_0x442950);_0x45c3cf(null);})[_0xf769('0xd')](_0x45c3cf(null));};}for(var e in events){if(events[_0xf769('0xe')](e)){var event=events[e];FaxInteraction[_0xf769('0xf')](e,emitEvent(event));}}module[_0xf769('0x10')]=FaxInteractionEvents;