bef5eaa997e3d749cc3eaaf0f686fc51e57ca65a
[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 _0x7d5e=['update','getUsers','then','setDataValue','findAll','length','emit','hasOwnProperty','hook','../../mysqldb','FaxInteraction','FaxMessage','setMaxListeners','save'];(function(_0x309991,_0x457e73){var _0x4ca94d=function(_0x294acc){while(--_0x294acc){_0x309991['push'](_0x309991['shift']());}};_0x4ca94d(++_0x457e73);}(_0x7d5e,0xbf));var _0xe7d5=function(_0x5a9781,_0x560943){_0x5a9781=_0x5a9781-0x0;var _0xa8a685=_0x7d5e[_0x5a9781];return _0xa8a685;};'use strict';var EventEmitter=require('events');var FaxInteraction=require(_0xe7d5('0x0'))['db'][_0xe7d5('0x1')];var FaxMessage=require(_0xe7d5('0x0'))['db'][_0xe7d5('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xe7d5('0x3')](0x0);var events={'afterCreate':_0xe7d5('0x4'),'afterUpdate':_0xe7d5('0x5'),'afterDestroy':'remove'};function emitEvent(_0x506d76){return function(_0x3d0638,_0x4b540c,_0x3c8d87){_0x3d0638[_0xe7d5('0x6')]({'attributes':['id'],'raw':!![]})[_0xe7d5('0x7')](function(_0x2919c1){_0x3d0638[_0xe7d5('0x8')]('Users',_0x2919c1['map'](function(_0x1583cf){return{'id':_0x1583cf['id']};}));return FaxMessage[_0xe7d5('0x9')]({'where':{'FaxInteractionId':_0x3d0638['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x3feb1d){_0x3d0638[_0xe7d5('0x8')]('unreadMessages',_0x3feb1d[_0xe7d5('0xa')]);FaxInteractionEvents[_0xe7d5('0xb')](_0x506d76+':'+_0x3d0638['id'],_0x3d0638);FaxInteractionEvents[_0xe7d5('0xb')](_0x506d76,_0x3d0638);_0x3c8d87(null);})['catch'](_0x3c8d87(null));};}for(var e in events){if(events[_0xe7d5('0xc')](e)){var event=events[e];FaxInteraction[_0xe7d5('0xd')](e,emitEvent(event));}}module['exports']=FaxInteractionEvents;