Built motion from commit ddca4d0d.|2.5.47
[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 _0xf6e8=['../../mysqldb','FaxInteraction','setMaxListeners','save','update','remove','getUsers','setDataValue','Users','map','then','unreadMessages','emit','catch','hasOwnProperty','hook','events'];(function(_0x502c7d,_0x2f1285){var _0x30b7ed=function(_0x2d92f3){while(--_0x2d92f3){_0x502c7d['push'](_0x502c7d['shift']());}};_0x30b7ed(++_0x2f1285);}(_0xf6e8,0x98));var _0x8f6e=function(_0x1af7eb,_0x28a856){_0x1af7eb=_0x1af7eb-0x0;var _0x9ae272=_0xf6e8[_0x1af7eb];return _0x9ae272;};'use strict';var EventEmitter=require(_0x8f6e('0x0'));var FaxInteraction=require(_0x8f6e('0x1'))['db'][_0x8f6e('0x2')];var FaxMessage=require(_0x8f6e('0x1'))['db']['FaxMessage'];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x8f6e('0x3')](0x0);var events={'afterCreate':_0x8f6e('0x4'),'afterUpdate':_0x8f6e('0x5'),'afterDestroy':_0x8f6e('0x6')};function emitEvent(_0xaeacf4){return function(_0x2a7f3b,_0x3ccf0c,_0x44e126){_0x2a7f3b[_0x8f6e('0x7')]({'attributes':['id'],'raw':!![]})['then'](function(_0x21116d){_0x2a7f3b[_0x8f6e('0x8')](_0x8f6e('0x9'),_0x21116d[_0x8f6e('0xa')](function(_0x268c63){return{'id':_0x268c63['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0x2a7f3b['id'],'direction':'in','read':![]},'raw':!![]});})[_0x8f6e('0xb')](function(_0x5366af){_0x2a7f3b[_0x8f6e('0x8')](_0x8f6e('0xc'),_0x5366af['length']);FaxInteractionEvents[_0x8f6e('0xd')](_0xaeacf4+':'+_0x2a7f3b['id'],_0x2a7f3b);FaxInteractionEvents[_0x8f6e('0xd')](_0xaeacf4,_0x2a7f3b);_0x44e126(null);})[_0x8f6e('0xe')](_0x44e126(null));};}for(var e in events){if(events[_0x8f6e('0xf')](e)){var event=events[e];FaxInteraction[_0x8f6e('0x10')](e,emitEvent(event));}}module['exports']=FaxInteractionEvents;