Built motion from commit 14588770.|2.5.38
[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 _0x9f25=['setMaxListeners','save','update','remove','getUsers','then','setDataValue','Users','map','unreadMessages','length','emit','catch','hasOwnProperty','hook','events','../../mysqldb','FaxInteraction','FaxMessage'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x9f25,0x12c));var _0x59f2=function(_0x3d1996,_0x1f08f0){_0x3d1996=_0x3d1996-0x0;var _0x550afd=_0x9f25[_0x3d1996];return _0x550afd;};'use strict';var EventEmitter=require(_0x59f2('0x0'));var FaxInteraction=require(_0x59f2('0x1'))['db'][_0x59f2('0x2')];var FaxMessage=require(_0x59f2('0x1'))['db'][_0x59f2('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x59f2('0x4')](0x0);var events={'afterCreate':_0x59f2('0x5'),'afterUpdate':_0x59f2('0x6'),'afterDestroy':_0x59f2('0x7')};function emitEvent(_0x20cf3a){return function(_0x4fa4a5,_0x51c0ac,_0x312efd){_0x4fa4a5[_0x59f2('0x8')]({'attributes':['id'],'raw':!![]})[_0x59f2('0x9')](function(_0x3ebb8f){_0x4fa4a5[_0x59f2('0xa')](_0x59f2('0xb'),_0x3ebb8f[_0x59f2('0xc')](function(_0x229b2a){return{'id':_0x229b2a['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0x4fa4a5['id'],'direction':'in','read':![]},'raw':!![]});})[_0x59f2('0x9')](function(_0x201fbd){_0x4fa4a5[_0x59f2('0xa')](_0x59f2('0xd'),_0x201fbd[_0x59f2('0xe')]);FaxInteractionEvents['emit'](_0x20cf3a+':'+_0x4fa4a5['id'],_0x4fa4a5);FaxInteractionEvents[_0x59f2('0xf')](_0x20cf3a,_0x4fa4a5);_0x312efd(null);})[_0x59f2('0x10')](_0x312efd(null));};}for(var e in events){if(events[_0x59f2('0x11')](e)){var event=events[e];FaxInteraction[_0x59f2('0x12')](e,emitEvent(event));}}module['exports']=FaxInteractionEvents;