60fa3706e32472f4b5aa70849abe59eb51bcd1f3
[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 _0x38b7=['hasOwnProperty','hook','exports','events','FaxInteraction','../../mysqldb','FaxMessage','save','update','remove','getUsers','Users','map','findAll','then','setDataValue','unreadMessages','emit','catch'];(function(_0x52764f,_0xdd7611){var _0x48c128=function(_0x4817c3){while(--_0x4817c3){_0x52764f['push'](_0x52764f['shift']());}};_0x48c128(++_0xdd7611);}(_0x38b7,0x9b));var _0x738b=function(_0x36f5bf,_0x38d7fd){_0x36f5bf=_0x36f5bf-0x0;var _0x23e6be=_0x38b7[_0x36f5bf];return _0x23e6be;};'use strict';var EventEmitter=require(_0x738b('0x0'));var FaxInteraction=require('../../mysqldb')['db'][_0x738b('0x1')];var FaxMessage=require(_0x738b('0x2'))['db'][_0x738b('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x738b('0x4'),'afterUpdate':_0x738b('0x5'),'afterDestroy':_0x738b('0x6')};function emitEvent(_0x26db5c){return function(_0x4d04cb,_0xa1dcbe,_0x413f1f){_0x4d04cb[_0x738b('0x7')]({'attributes':['id'],'raw':!![]})['then'](function(_0x156b4b){_0x4d04cb['setDataValue'](_0x738b('0x8'),_0x156b4b[_0x738b('0x9')](function(_0x16a1df){return{'id':_0x16a1df['id']};}));return FaxMessage[_0x738b('0xa')]({'where':{'FaxInteractionId':_0x4d04cb['id'],'direction':'in','read':![]},'raw':!![]});})[_0x738b('0xb')](function(_0xa57c60){_0x4d04cb[_0x738b('0xc')](_0x738b('0xd'),_0xa57c60['length']);FaxInteractionEvents['emit'](_0x26db5c+':'+_0x4d04cb['id'],_0x4d04cb);FaxInteractionEvents[_0x738b('0xe')](_0x26db5c,_0x4d04cb);_0x413f1f(null);})[_0x738b('0xf')](_0x413f1f(null));};}for(var e in events){if(events[_0x738b('0x10')](e)){var event=events[e];FaxInteraction[_0x738b('0x11')](e,emitEvent(event));}}module[_0x738b('0x12')]=FaxInteractionEvents;