a7fa717c2c63ad8e6df43e7bd7a5ec40b2bb05ea
[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 _0x22fe=['FaxMessage','setMaxListeners','save','update','getUsers','then','setDataValue','Users','findAll','unreadMessages','length','emit','catch','hasOwnProperty','exports','events','../../mysqldb','FaxInteraction'];(function(_0x335bd7,_0x4ac64b){var _0x291faa=function(_0x7ee182){while(--_0x7ee182){_0x335bd7['push'](_0x335bd7['shift']());}};_0x291faa(++_0x4ac64b);}(_0x22fe,0x177));var _0xe22f=function(_0x5bc84c,_0x38d001){_0x5bc84c=_0x5bc84c-0x0;var _0x612a54=_0x22fe[_0x5bc84c];return _0x612a54;};'use strict';var EventEmitter=require(_0xe22f('0x0'));var FaxInteraction=require(_0xe22f('0x1'))['db'][_0xe22f('0x2')];var FaxMessage=require(_0xe22f('0x1'))['db'][_0xe22f('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xe22f('0x4')](0x0);var events={'afterCreate':_0xe22f('0x5'),'afterUpdate':_0xe22f('0x6'),'afterDestroy':'remove'};function emitEvent(_0x45554a){return function(_0x38c42b,_0x180e42,_0x1f5f3d){_0x38c42b[_0xe22f('0x7')]({'attributes':['id'],'raw':!![]})[_0xe22f('0x8')](function(_0x55db9c){_0x38c42b[_0xe22f('0x9')](_0xe22f('0xa'),_0x55db9c['map'](function(_0x482b9b){return{'id':_0x482b9b['id']};}));return FaxMessage[_0xe22f('0xb')]({'where':{'FaxInteractionId':_0x38c42b['id'],'direction':'in','read':![]},'raw':!![]});})[_0xe22f('0x8')](function(_0x22c2a6){_0x38c42b[_0xe22f('0x9')](_0xe22f('0xc'),_0x22c2a6[_0xe22f('0xd')]);FaxInteractionEvents['emit'](_0x45554a+':'+_0x38c42b['id'],_0x38c42b);FaxInteractionEvents[_0xe22f('0xe')](_0x45554a,_0x38c42b);_0x1f5f3d(null);})[_0xe22f('0xf')](_0x1f5f3d(null));};}for(var e in events){if(events[_0xe22f('0x10')](e)){var event=events[e];FaxInteraction['hook'](e,emitEvent(event));}}module[_0xe22f('0x11')]=FaxInteractionEvents;