a19a6dc1056baf4a24f9023fe2843e71daa65dcf
[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 _0x30ab=['unreadMessages','emit','hasOwnProperty','events','FaxMessage','setMaxListeners','save','update','remove','getUsers','then','map','setDataValue'];(function(_0x13c82f,_0x353a63){var _0x117e17=function(_0xeeabe7){while(--_0xeeabe7){_0x13c82f['push'](_0x13c82f['shift']());}};_0x117e17(++_0x353a63);}(_0x30ab,0x6b));var _0xb30a=function(_0x6b0702,_0x1e459f){_0x6b0702=_0x6b0702-0x0;var _0x126c0f=_0x30ab[_0x6b0702];return _0x126c0f;};'use strict';var EventEmitter=require(_0xb30a('0x0'));var FaxInteraction=require('../../mysqldb')['db']['FaxInteraction'];var FaxMessage=require('../../mysqldb')['db'][_0xb30a('0x1')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xb30a('0x2')](0x0);var events={'afterCreate':_0xb30a('0x3'),'afterUpdate':_0xb30a('0x4'),'afterDestroy':_0xb30a('0x5')};function emitEvent(_0x29dccf){return function(_0x4669e5,_0x15937d,_0x1de920){_0x4669e5[_0xb30a('0x6')]({'attributes':['id'],'raw':!![]})[_0xb30a('0x7')](function(_0x228a33){_0x4669e5['setDataValue']('Users',_0x228a33[_0xb30a('0x8')](function(_0x101789){return{'id':_0x101789['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0x4669e5['id'],'direction':'in','read':![]},'raw':!![]});})[_0xb30a('0x7')](function(_0x24f277){_0x4669e5[_0xb30a('0x9')](_0xb30a('0xa'),_0x24f277['length']);FaxInteractionEvents[_0xb30a('0xb')](_0x29dccf+':'+_0x4669e5['id'],_0x4669e5);FaxInteractionEvents[_0xb30a('0xb')](_0x29dccf,_0x4669e5);_0x1de920(null);})['catch'](_0x1de920(null));};}for(var e in events){if(events[_0xb30a('0xc')](e)){var event=events[e];FaxInteraction['hook'](e,emitEvent(event));}}module['exports']=FaxInteractionEvents;