e4ba32a7aa7f0c552fe649c38edbb10dedcd770b
[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 _0x2ccf=['map','findAll','setDataValue','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','FaxInteraction','setMaxListeners','remove','getUsers','then','Users'];(function(_0x1d5fb9,_0x43aa73){var _0xd72009=function(_0x44052e){while(--_0x44052e){_0x1d5fb9['push'](_0x1d5fb9['shift']());}};_0xd72009(++_0x43aa73);}(_0x2ccf,0x1e5));var _0xf2cc=function(_0x5c50f0,_0x2c9b49){_0x5c50f0=_0x5c50f0-0x0;var _0x25d2b4=_0x2ccf[_0x5c50f0];return _0x25d2b4;};'use strict';var EventEmitter=require(_0xf2cc('0x0'));var FaxInteraction=require(_0xf2cc('0x1'))['db'][_0xf2cc('0x2')];var FaxMessage=require('../../mysqldb')['db']['FaxMessage'];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xf2cc('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':_0xf2cc('0x4')};function emitEvent(_0x5922fd){return function(_0x4a8465,_0x3fe59c,_0x583cb9){_0x4a8465[_0xf2cc('0x5')]({'attributes':['id'],'raw':!![]})[_0xf2cc('0x6')](function(_0x488a5f){_0x4a8465['setDataValue'](_0xf2cc('0x7'),_0x488a5f[_0xf2cc('0x8')](function(_0x563218){return{'id':_0x563218['id']};}));return FaxMessage[_0xf2cc('0x9')]({'where':{'FaxInteractionId':_0x4a8465['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf2cc('0x6')](function(_0x1927dc){_0x4a8465[_0xf2cc('0xa')]('unreadMessages',_0x1927dc[_0xf2cc('0xb')]);FaxInteractionEvents[_0xf2cc('0xc')](_0x5922fd+':'+_0x4a8465['id'],_0x4a8465);FaxInteractionEvents[_0xf2cc('0xc')](_0x5922fd,_0x4a8465);_0x583cb9(null);})[_0xf2cc('0xd')](_0x583cb9(null));};}for(var e in events){if(events[_0xf2cc('0xe')](e)){var event=events[e];FaxInteraction[_0xf2cc('0xf')](e,emitEvent(event));}}module[_0xf2cc('0x10')]=FaxInteractionEvents;