Built motion from commit 67e5df37.|2.0.66
[motion2.git] / server / services / routing / realtime / index.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 _0x69f9=['../model/agent','../model/interval','../model/openchannelQueue','../model/chatQueue','../model/smsQueue','../model/mailQueue','../model/faxQueue','agents','intervals','openchannelQueues','smsQueues','mailQueues','faxQueues','mailQueuesWaitingInteractions','smsQueuesWaitingInteractions','hasOwnProperty','mergeFromDatabase','prototype','initAgents','isUndefined','initIntervals','length','updateRouting','updateRealtime','initChatQueues','chatQueues','initSmsQueues','initFaxQueues','bluebird','util','lodash','moment'];(function(_0x20af86,_0x31ffe6){var _0x5a9dee=function(_0x204569){while(--_0x204569){_0x20af86['push'](_0x20af86['shift']());}};_0x5a9dee(++_0x31ffe6);}(_0x69f9,0x11c));var _0x969f=function(_0x2d1861,_0x2cce00){_0x2d1861=_0x2d1861-0x0;var _0x3d660f=_0x69f9[_0x2d1861];return _0x3d660f;};'use strict';var BPromise=require(_0x969f('0x0'));var util=require(_0x969f('0x1'));var _=require(_0x969f('0x2'));var moment=require(_0x969f('0x3'));var Agent=require(_0x969f('0x4'));var Interval=require(_0x969f('0x5'));var OpenchannelQueue=require(_0x969f('0x6'));var ChatQueue=require(_0x969f('0x7'));var SmsQueue=require(_0x969f('0x8'));var MailQueue=require(_0x969f('0x9'));var FaxQueue=require(_0x969f('0xa'));var Realtime=function(){this[_0x969f('0xb')]={};this[_0x969f('0xc')]={};this[_0x969f('0xd')]={};this['chatQueues']={};this[_0x969f('0xe')]={};this[_0x969f('0xf')]={};this[_0x969f('0x10')]={};this['chatQueuesWaitingInteractions']={};this[_0x969f('0x11')]={};this['openchannelQueuesWaitingInteractions']={};this[_0x969f('0x12')]={};this['faxQueuesWaitingInteractions']={};};function freeIsNotKey(_0x463093,_0xeb803e,_0x3c63ed){var _0x11f831=_['mapKeys'](_0x463093,function(_0x57363c,_0x5e83a5){return _0x57363c[_0x3c63ed];});for(var _0x3abd85 in _0xeb803e){if(_0xeb803e[_0x969f('0x13')](_0x3abd85)){if(!_0x11f831[_0x3abd85]){delete _0xeb803e[_0x3abd85];}}}}Realtime['prototype'][_0x969f('0x14')]=function(_0x4ed69a,_0xa5a126){for(var _0x1eeaa9 in _0xa5a126){if(_0x4ed69a[_0x969f('0x13')](_0x1eeaa9)){_0x4ed69a[_0x1eeaa9]=_0xa5a126[_0x1eeaa9];}}};Realtime[_0x969f('0x15')][_0x969f('0x16')]=function(){var _0x21de68=this;return function(_0x42b8ed){if(_0x42b8ed){freeIsNotKey(_0x42b8ed,_0x21de68[_0x969f('0xb')],'id');for(var _0x3f7f80=0x0,_0x3e162d={},_0x3ee703={};_0x3f7f80<_0x42b8ed['length'];_0x3f7f80+=0x1){_0x3e162d=_0x42b8ed[_0x3f7f80];if(_[_0x969f('0x17')](_0x21de68[_0x969f('0xb')][_0x3e162d['id']])){_0x21de68['agents'][_0x3e162d['id']]=new Agent(_0x3e162d);}else{_0x21de68[_0x969f('0x14')](_0x21de68['agents'][_0x3e162d['id']],_0x3e162d);}}}return _0x21de68[_0x969f('0xb')];};};Realtime[_0x969f('0x15')][_0x969f('0x18')]=function(){var _0x32cacb=this;return function(_0x35e3df){if(_0x35e3df){freeIsNotKey(_0x35e3df,_0x32cacb[_0x969f('0xc')],'id');for(var _0x54d7b8=0x0,_0x2f3bde={},_0x5b2034={};_0x54d7b8<_0x35e3df[_0x969f('0x19')];_0x54d7b8+=0x1){_0x2f3bde=_0x35e3df[_0x54d7b8];if(_[_0x969f('0x17')](_0x32cacb[_0x969f('0xc')][_0x2f3bde['id']])){_0x32cacb[_0x969f('0xc')][_0x2f3bde['id']]=new Interval(_0x2f3bde);}else{_0x32cacb[_0x969f('0x14')](_0x32cacb['intervals'][_0x2f3bde['id']],_0x2f3bde);}}}return _0x32cacb[_0x969f('0xc')];};};Realtime[_0x969f('0x15')]['initOpenchannelQueues']=function(){var _0x2e0233=this;return function(_0x3261cd){if(_0x3261cd){freeIsNotKey(_0x3261cd,_0x2e0233[_0x969f('0xd')],'id');for(var _0x5b6453=0x0,_0x5f0a1f={},_0x332382={};_0x5b6453<_0x3261cd['length'];_0x5b6453+=0x1){_0x5f0a1f=_0x3261cd[_0x5b6453];if(_['isUndefined'](_0x2e0233[_0x969f('0xd')][_0x5f0a1f['id']])){_0x2e0233['openchannelQueues'][_0x5f0a1f['id']]=new OpenchannelQueue(_0x5f0a1f);}else{_0x2e0233[_0x969f('0x14')](_0x2e0233['openchannelQueues'][_0x5f0a1f['id']],_0x5f0a1f);}_0x2e0233[_0x969f('0xd')][_0x5f0a1f['id']][_0x969f('0x1a')]();_0x2e0233[_0x969f('0xd')][_0x5f0a1f['id']][_0x969f('0x1b')]();}}return _0x2e0233['openchannelQueues'];};};Realtime[_0x969f('0x15')][_0x969f('0x1c')]=function(){var _0x393ab6=this;return function(_0x1d5244){if(_0x1d5244){freeIsNotKey(_0x1d5244,_0x393ab6[_0x969f('0x1d')],'id');for(var _0x4469ca=0x0,_0x47a437={},_0x4e033={};_0x4469ca<_0x1d5244[_0x969f('0x19')];_0x4469ca+=0x1){_0x47a437=_0x1d5244[_0x4469ca];if(_['isUndefined'](_0x393ab6[_0x969f('0x1d')][_0x47a437['id']])){_0x393ab6[_0x969f('0x1d')][_0x47a437['id']]=new ChatQueue(_0x47a437);}else{_0x393ab6[_0x969f('0x14')](_0x393ab6[_0x969f('0x1d')][_0x47a437['id']],_0x47a437);}_0x393ab6[_0x969f('0x1d')][_0x47a437['id']][_0x969f('0x1a')]();_0x393ab6[_0x969f('0x1d')][_0x47a437['id']]['updateRealtime']();}}return _0x393ab6[_0x969f('0x1d')];};};Realtime[_0x969f('0x15')][_0x969f('0x1e')]=function(){var _0x5d8051=this;return function(_0x1fcf9d){if(_0x1fcf9d){freeIsNotKey(_0x1fcf9d,_0x5d8051[_0x969f('0xe')],'id');for(var _0x3387a6=0x0,_0x891aec={},_0x40ed17={};_0x3387a6<_0x1fcf9d[_0x969f('0x19')];_0x3387a6+=0x1){_0x891aec=_0x1fcf9d[_0x3387a6];if(_[_0x969f('0x17')](_0x5d8051[_0x969f('0xe')][_0x891aec['id']])){_0x5d8051[_0x969f('0xe')][_0x891aec['id']]=new SmsQueue(_0x891aec);}else{_0x5d8051[_0x969f('0x14')](_0x5d8051['smsQueues'][_0x891aec['id']],_0x891aec);}_0x5d8051['smsQueues'][_0x891aec['id']]['updateRouting']();_0x5d8051[_0x969f('0xe')][_0x891aec['id']][_0x969f('0x1b')]();}}return _0x5d8051[_0x969f('0xe')];};};Realtime['prototype']['initMailQueues']=function(){var _0x41bd65=this;return function(_0x4c7495){if(_0x4c7495){freeIsNotKey(_0x4c7495,_0x41bd65['mailQueues'],'id');for(var _0x52b31f=0x0,_0x2dd988={},_0x13e047={};_0x52b31f<_0x4c7495[_0x969f('0x19')];_0x52b31f+=0x1){_0x2dd988=_0x4c7495[_0x52b31f];if(_['isUndefined'](_0x41bd65['mailQueues'][_0x2dd988['id']])){_0x41bd65[_0x969f('0xf')][_0x2dd988['id']]=new MailQueue(_0x2dd988);}else{_0x41bd65[_0x969f('0x14')](_0x41bd65[_0x969f('0xf')][_0x2dd988['id']],_0x2dd988);}_0x41bd65[_0x969f('0xf')][_0x2dd988['id']][_0x969f('0x1a')]();_0x41bd65[_0x969f('0xf')][_0x2dd988['id']]['updateRealtime']();}}return _0x41bd65[_0x969f('0xf')];};};Realtime[_0x969f('0x15')][_0x969f('0x1f')]=function(){var _0x31efe8=this;return function(_0x380eae){if(_0x380eae){freeIsNotKey(_0x380eae,_0x31efe8[_0x969f('0x10')],'id');for(var _0x5e011f=0x0,_0x2bd118={},_0x59916c={};_0x5e011f<_0x380eae[_0x969f('0x19')];_0x5e011f+=0x1){_0x2bd118=_0x380eae[_0x5e011f];if(_[_0x969f('0x17')](_0x31efe8[_0x969f('0x10')][_0x2bd118['id']])){_0x31efe8['faxQueues'][_0x2bd118['id']]=new FaxQueue(_0x2bd118);}else{_0x31efe8['mergeFromDatabase'](_0x31efe8[_0x969f('0x10')][_0x2bd118['id']],_0x2bd118);}_0x31efe8[_0x969f('0x10')][_0x2bd118['id']][_0x969f('0x1a')]();_0x31efe8[_0x969f('0x10')][_0x2bd118['id']][_0x969f('0x1b')]();}}return _0x31efe8[_0x969f('0x10')];};};module['exports']=Realtime;