Built motion from commit (unavailable).|2.4.20
[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 _0xbcf9=['openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','mapKeys','hasOwnProperty','mergeFromDatabase','prototype','initAgents','length','initIntervals','intervals','isUndefined','initOpenchannelQueues','openchannelQueues','updateRouting','updateRealtime','chatQueues','initSmsQueues','initMailQueues','initFaxQueues','faxQueues','exports','util','../model/agent','../model/interval','../model/openchannelQueue','../model/chatQueue','../model/smsQueue','../model/mailQueue','../model/faxQueue','agents','smsQueues','mailQueues','chatQueuesWaitingInteractions','mailQueuesWaitingInteractions'];(function(_0x3cb30b,_0x504b3e){var _0x2ca717=function(_0x32a3d9){while(--_0x32a3d9){_0x3cb30b['push'](_0x3cb30b['shift']());}};_0x2ca717(++_0x504b3e);}(_0xbcf9,0x7f));var _0x9bcf=function(_0x5b1c0a,_0x17a41e){_0x5b1c0a=_0x5b1c0a-0x0;var _0x3a8609=_0xbcf9[_0x5b1c0a];return _0x3a8609;};'use strict';var BPromise=require('bluebird');var util=require(_0x9bcf('0x0'));var _=require('lodash');var moment=require('moment');var Agent=require(_0x9bcf('0x1'));var Interval=require(_0x9bcf('0x2'));var OpenchannelQueue=require(_0x9bcf('0x3'));var ChatQueue=require(_0x9bcf('0x4'));var SmsQueue=require(_0x9bcf('0x5'));var MailQueue=require(_0x9bcf('0x6'));var FaxQueue=require(_0x9bcf('0x7'));var Realtime=function(){this[_0x9bcf('0x8')]={};this['intervals']={};this['openchannelQueues']={};this['chatQueues']={};this[_0x9bcf('0x9')]={};this[_0x9bcf('0xa')]={};this['faxQueues']={};this[_0x9bcf('0xb')]={};this[_0x9bcf('0xc')]={};this[_0x9bcf('0xd')]={};this[_0x9bcf('0xe')]={};this[_0x9bcf('0xf')]={};};function freeIsNotKey(_0x998d07,_0x436430,_0x223f06){var _0x47bfac=_[_0x9bcf('0x10')](_0x998d07,function(_0xff7074,_0x5166a1){return _0xff7074[_0x223f06];});for(var _0x1af3a8 in _0x436430){if(_0x436430[_0x9bcf('0x11')](_0x1af3a8)){if(!_0x47bfac[_0x1af3a8]){delete _0x436430[_0x1af3a8];}}}}Realtime['prototype'][_0x9bcf('0x12')]=function(_0x40193b,_0x23aeed){for(var _0x288fdf in _0x23aeed){if(_0x40193b['hasOwnProperty'](_0x288fdf)){_0x40193b[_0x288fdf]=_0x23aeed[_0x288fdf];}}};Realtime[_0x9bcf('0x13')][_0x9bcf('0x14')]=function(){var _0xa832a5=this;return function(_0x4d1311){if(_0x4d1311){freeIsNotKey(_0x4d1311,_0xa832a5[_0x9bcf('0x8')],'id');for(var _0x12887e=0x0,_0x39bde6={},_0xc26f50={};_0x12887e<_0x4d1311[_0x9bcf('0x15')];_0x12887e+=0x1){_0x39bde6=_0x4d1311[_0x12887e];if(_['isUndefined'](_0xa832a5[_0x9bcf('0x8')][_0x39bde6['id']])){_0xa832a5[_0x9bcf('0x8')][_0x39bde6['id']]=new Agent(_0x39bde6);}else{_0xa832a5[_0x9bcf('0x12')](_0xa832a5[_0x9bcf('0x8')][_0x39bde6['id']],_0x39bde6);}}}return _0xa832a5['agents'];};};Realtime['prototype'][_0x9bcf('0x16')]=function(){var _0x5de116=this;return function(_0x2dfb11){if(_0x2dfb11){freeIsNotKey(_0x2dfb11,_0x5de116[_0x9bcf('0x17')],'id');for(var _0x50598a=0x0,_0x43fb81={},_0x9d4bb7={};_0x50598a<_0x2dfb11[_0x9bcf('0x15')];_0x50598a+=0x1){_0x43fb81=_0x2dfb11[_0x50598a];if(_[_0x9bcf('0x18')](_0x5de116[_0x9bcf('0x17')][_0x43fb81['id']])){_0x5de116[_0x9bcf('0x17')][_0x43fb81['id']]=new Interval(_0x43fb81);}else{_0x5de116[_0x9bcf('0x12')](_0x5de116['intervals'][_0x43fb81['id']],_0x43fb81);}}}return _0x5de116['intervals'];};};Realtime[_0x9bcf('0x13')][_0x9bcf('0x19')]=function(){var _0xd1cce3=this;return function(_0x2c335e){if(_0x2c335e){freeIsNotKey(_0x2c335e,_0xd1cce3['openchannelQueues'],'id');for(var _0x1e9495=0x0,_0x50fb04={},_0x23c23e={};_0x1e9495<_0x2c335e[_0x9bcf('0x15')];_0x1e9495+=0x1){_0x50fb04=_0x2c335e[_0x1e9495];if(_[_0x9bcf('0x18')](_0xd1cce3['openchannelQueues'][_0x50fb04['id']])){_0xd1cce3[_0x9bcf('0x1a')][_0x50fb04['id']]=new OpenchannelQueue(_0x50fb04);}else{_0xd1cce3['mergeFromDatabase'](_0xd1cce3['openchannelQueues'][_0x50fb04['id']],_0x50fb04);}_0xd1cce3[_0x9bcf('0x1a')][_0x50fb04['id']][_0x9bcf('0x1b')]();_0xd1cce3[_0x9bcf('0x1a')][_0x50fb04['id']][_0x9bcf('0x1c')]();}}return _0xd1cce3['openchannelQueues'];};};Realtime['prototype']['initChatQueues']=function(){var _0x406702=this;return function(_0x3cc50b){if(_0x3cc50b){freeIsNotKey(_0x3cc50b,_0x406702[_0x9bcf('0x1d')],'id');for(var _0x21b7ea=0x0,_0x2fd797={},_0x54c2ef={};_0x21b7ea<_0x3cc50b[_0x9bcf('0x15')];_0x21b7ea+=0x1){_0x2fd797=_0x3cc50b[_0x21b7ea];if(_[_0x9bcf('0x18')](_0x406702['chatQueues'][_0x2fd797['id']])){_0x406702['chatQueues'][_0x2fd797['id']]=new ChatQueue(_0x2fd797);}else{_0x406702[_0x9bcf('0x12')](_0x406702[_0x9bcf('0x1d')][_0x2fd797['id']],_0x2fd797);}_0x406702[_0x9bcf('0x1d')][_0x2fd797['id']][_0x9bcf('0x1b')]();_0x406702[_0x9bcf('0x1d')][_0x2fd797['id']][_0x9bcf('0x1c')]();}}return _0x406702['chatQueues'];};};Realtime[_0x9bcf('0x13')][_0x9bcf('0x1e')]=function(){var _0x329056=this;return function(_0x14b31a){if(_0x14b31a){freeIsNotKey(_0x14b31a,_0x329056[_0x9bcf('0x9')],'id');for(var _0x109c1c=0x0,_0xfb2a05={},_0x51d84c={};_0x109c1c<_0x14b31a[_0x9bcf('0x15')];_0x109c1c+=0x1){_0xfb2a05=_0x14b31a[_0x109c1c];if(_[_0x9bcf('0x18')](_0x329056[_0x9bcf('0x9')][_0xfb2a05['id']])){_0x329056[_0x9bcf('0x9')][_0xfb2a05['id']]=new SmsQueue(_0xfb2a05);}else{_0x329056[_0x9bcf('0x12')](_0x329056[_0x9bcf('0x9')][_0xfb2a05['id']],_0xfb2a05);}_0x329056[_0x9bcf('0x9')][_0xfb2a05['id']]['updateRouting']();_0x329056['smsQueues'][_0xfb2a05['id']][_0x9bcf('0x1c')]();}}return _0x329056[_0x9bcf('0x9')];};};Realtime[_0x9bcf('0x13')][_0x9bcf('0x1f')]=function(){var _0x5b3836=this;return function(_0x27f91f){if(_0x27f91f){freeIsNotKey(_0x27f91f,_0x5b3836[_0x9bcf('0xa')],'id');for(var _0x4d3512=0x0,_0x2b6e11={},_0x43cb17={};_0x4d3512<_0x27f91f['length'];_0x4d3512+=0x1){_0x2b6e11=_0x27f91f[_0x4d3512];if(_['isUndefined'](_0x5b3836[_0x9bcf('0xa')][_0x2b6e11['id']])){_0x5b3836[_0x9bcf('0xa')][_0x2b6e11['id']]=new MailQueue(_0x2b6e11);}else{_0x5b3836[_0x9bcf('0x12')](_0x5b3836[_0x9bcf('0xa')][_0x2b6e11['id']],_0x2b6e11);}_0x5b3836[_0x9bcf('0xa')][_0x2b6e11['id']]['updateRouting']();_0x5b3836[_0x9bcf('0xa')][_0x2b6e11['id']]['updateRealtime']();}}return _0x5b3836[_0x9bcf('0xa')];};};Realtime[_0x9bcf('0x13')][_0x9bcf('0x20')]=function(){var _0x34e563=this;return function(_0x514484){if(_0x514484){freeIsNotKey(_0x514484,_0x34e563[_0x9bcf('0x21')],'id');for(var _0x42e7c9=0x0,_0x5cec49={},_0x4ac64a={};_0x42e7c9<_0x514484[_0x9bcf('0x15')];_0x42e7c9+=0x1){_0x5cec49=_0x514484[_0x42e7c9];if(_[_0x9bcf('0x18')](_0x34e563[_0x9bcf('0x21')][_0x5cec49['id']])){_0x34e563[_0x9bcf('0x21')][_0x5cec49['id']]=new FaxQueue(_0x5cec49);}else{_0x34e563[_0x9bcf('0x12')](_0x34e563['faxQueues'][_0x5cec49['id']],_0x5cec49);}_0x34e563[_0x9bcf('0x21')][_0x5cec49['id']][_0x9bcf('0x1b')]();_0x34e563[_0x9bcf('0x21')][_0x5cec49['id']]['updateRealtime']();}}return _0x34e563['faxQueues'];};};module[_0x9bcf('0x22')]=Realtime;