5d5b94a9f92efb456b2439ec687ab3f5d7236879
[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 _0x3dc4=['setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','FaxInteraction','FaxMessage','save','remove','getUsers','then'];(function(_0x47f653,_0x34342a){var _0xc1d822=function(_0x3f4005){while(--_0x3f4005){_0x47f653['push'](_0x47f653['shift']());}};_0xc1d822(++_0x34342a);}(_0x3dc4,0x1d3));var _0x43dc=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x3dc4[_0x3dd15e];return _0x231fd0;};'use strict';var EventEmitter=require(_0x43dc('0x0'));var FaxInteraction=require(_0x43dc('0x1'))['db'][_0x43dc('0x2')];var FaxMessage=require(_0x43dc('0x1'))['db'][_0x43dc('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x43dc('0x4'),'afterUpdate':'update','afterDestroy':_0x43dc('0x5')};function emitEvent(_0x57f9d0){return function(_0x5ccebb,_0x4a443b,_0x420173){_0x5ccebb[_0x43dc('0x6')]({'attributes':['id'],'raw':!![]})[_0x43dc('0x7')](function(_0x1df06b){_0x5ccebb[_0x43dc('0x8')](_0x43dc('0x9'),_0x1df06b[_0x43dc('0xa')](function(_0x34cf4e){return{'id':_0x34cf4e['id']};}));return FaxMessage[_0x43dc('0xb')]({'where':{'FaxInteractionId':_0x5ccebb['id'],'direction':'in','read':![]},'raw':!![]});})[_0x43dc('0x7')](function(_0x59bcb9){_0x5ccebb[_0x43dc('0x8')](_0x43dc('0xc'),_0x59bcb9[_0x43dc('0xd')]);FaxInteractionEvents[_0x43dc('0xe')](_0x57f9d0+':'+_0x5ccebb['id'],_0x5ccebb);FaxInteractionEvents[_0x43dc('0xe')](_0x57f9d0,_0x5ccebb);_0x420173(null);})[_0x43dc('0xf')](_0x420173(null));};}for(var e in events){if(events[_0x43dc('0x10')](e)){var event=events[e];FaxInteraction[_0x43dc('0x11')](e,emitEvent(event));}}module[_0x43dc('0x12')]=FaxInteractionEvents;