Built motion from commit (unavailable).|2.5.8
[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 _0xa41a=['../model/interval','../model/openchannelQueue','../model/chatQueue','../model/smsQueue','../model/mailQueue','../model/faxQueue','agents','intervals','smsQueues','mailQueues','whatsappQueues','chatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','mapKeys','prototype','mergeFromDatabase','initAgents','length','isUndefined','initIntervals','initOpenchannelQueues','openchannelQueues','initChatQueues','chatQueues','initSmsQueues','updateRouting','updateRealtime','initFaxQueues','faxQueues','bluebird','util','moment','../model/agent'];(function(_0x2fe2dc,_0x49d2ac){var _0x37eeb3=function(_0x2006d2){while(--_0x2006d2){_0x2fe2dc['push'](_0x2fe2dc['shift']());}};_0x37eeb3(++_0x49d2ac);}(_0xa41a,0x6b));var _0xaa41=function(_0x4f096a,_0x5899d8){_0x4f096a=_0x4f096a-0x0;var _0x16981e=_0xa41a[_0x4f096a];return _0x16981e;};'use strict';var BPromise=require(_0xaa41('0x0'));var util=require(_0xaa41('0x1'));var _=require('lodash');var moment=require(_0xaa41('0x2'));var Agent=require(_0xaa41('0x3'));var Interval=require(_0xaa41('0x4'));var OpenchannelQueue=require(_0xaa41('0x5'));var ChatQueue=require(_0xaa41('0x6'));var SmsQueue=require(_0xaa41('0x7'));var MailQueue=require(_0xaa41('0x8'));var FaxQueue=require(_0xaa41('0x9'));var WhatsappQueue=require('../model/whatsappQueue');var Realtime=function(){this[_0xaa41('0xa')]={};this[_0xaa41('0xb')]={};this['openchannelQueues']={};this['chatQueues']={};this[_0xaa41('0xc')]={};this[_0xaa41('0xd')]={};this['faxQueues']={};this[_0xaa41('0xe')]={};this[_0xaa41('0xf')]={};this[_0xaa41('0x10')]={};this[_0xaa41('0x11')]={};this[_0xaa41('0x12')]={};this[_0xaa41('0x13')]={};this[_0xaa41('0x14')]={};};function freeIsNotKey(_0x423a19,_0x1c291e,_0x5c9fc7){var _0x1d3aac=_[_0xaa41('0x15')](_0x423a19,function(_0x524cab,_0x54827c){return _0x524cab[_0x5c9fc7];});for(var _0x1d0a54 in _0x1c291e){if(_0x1c291e['hasOwnProperty'](_0x1d0a54)){if(!_0x1d3aac[_0x1d0a54]){delete _0x1c291e[_0x1d0a54];}}}}Realtime[_0xaa41('0x16')][_0xaa41('0x17')]=function(_0x2f64bc,_0x889d44){for(var _0x6f9ade in _0x889d44){if(_0x2f64bc['hasOwnProperty'](_0x6f9ade)){_0x2f64bc[_0x6f9ade]=_0x889d44[_0x6f9ade];}}};Realtime[_0xaa41('0x16')][_0xaa41('0x18')]=function(){var _0x1934e9=this;return function(_0x1ef7d9){if(_0x1ef7d9){freeIsNotKey(_0x1ef7d9,_0x1934e9[_0xaa41('0xa')],'id');for(var _0x2005ae=0x0,_0x1e1e02={},_0x550ad5={};_0x2005ae<_0x1ef7d9[_0xaa41('0x19')];_0x2005ae+=0x1){_0x1e1e02=_0x1ef7d9[_0x2005ae];if(_[_0xaa41('0x1a')](_0x1934e9[_0xaa41('0xa')][_0x1e1e02['id']])){_0x1934e9[_0xaa41('0xa')][_0x1e1e02['id']]=new Agent(_0x1e1e02);}else{_0x1934e9[_0xaa41('0x17')](_0x1934e9[_0xaa41('0xa')][_0x1e1e02['id']],_0x1e1e02);}}}return _0x1934e9[_0xaa41('0xa')];};};Realtime[_0xaa41('0x16')][_0xaa41('0x1b')]=function(){var _0x4fe1a4=this;return function(_0x5cd936){if(_0x5cd936){freeIsNotKey(_0x5cd936,_0x4fe1a4[_0xaa41('0xb')],'id');for(var _0x22de55=0x0,_0x35c753={},_0x54c488={};_0x22de55<_0x5cd936[_0xaa41('0x19')];_0x22de55+=0x1){_0x35c753=_0x5cd936[_0x22de55];if(_[_0xaa41('0x1a')](_0x4fe1a4['intervals'][_0x35c753['id']])){_0x4fe1a4['intervals'][_0x35c753['id']]=new Interval(_0x35c753);}else{_0x4fe1a4[_0xaa41('0x17')](_0x4fe1a4['intervals'][_0x35c753['id']],_0x35c753);}}}return _0x4fe1a4[_0xaa41('0xb')];};};Realtime[_0xaa41('0x16')][_0xaa41('0x1c')]=function(){var _0x1f27f3=this;return function(_0x1d623c){if(_0x1d623c){freeIsNotKey(_0x1d623c,_0x1f27f3['openchannelQueues'],'id');for(var _0x43c430=0x0,_0x43a85c={},_0x448a21={};_0x43c430<_0x1d623c[_0xaa41('0x19')];_0x43c430+=0x1){_0x43a85c=_0x1d623c[_0x43c430];if(_[_0xaa41('0x1a')](_0x1f27f3[_0xaa41('0x1d')][_0x43a85c['id']])){_0x1f27f3['openchannelQueues'][_0x43a85c['id']]=new OpenchannelQueue(_0x43a85c);}else{_0x1f27f3['mergeFromDatabase'](_0x1f27f3[_0xaa41('0x1d')][_0x43a85c['id']],_0x43a85c);}_0x1f27f3['openchannelQueues'][_0x43a85c['id']]['updateRouting']();_0x1f27f3[_0xaa41('0x1d')][_0x43a85c['id']]['updateRealtime']();}}return _0x1f27f3['openchannelQueues'];};};Realtime[_0xaa41('0x16')][_0xaa41('0x1e')]=function(){var _0x392214=this;return function(_0x632fd2){if(_0x632fd2){freeIsNotKey(_0x632fd2,_0x392214[_0xaa41('0x1f')],'id');for(var _0xa7269f=0x0,_0x57ef96={},_0x30a174={};_0xa7269f<_0x632fd2[_0xaa41('0x19')];_0xa7269f+=0x1){_0x57ef96=_0x632fd2[_0xa7269f];if(_[_0xaa41('0x1a')](_0x392214[_0xaa41('0x1f')][_0x57ef96['id']])){_0x392214[_0xaa41('0x1f')][_0x57ef96['id']]=new ChatQueue(_0x57ef96);}else{_0x392214[_0xaa41('0x17')](_0x392214[_0xaa41('0x1f')][_0x57ef96['id']],_0x57ef96);}_0x392214[_0xaa41('0x1f')][_0x57ef96['id']]['updateRouting']();_0x392214[_0xaa41('0x1f')][_0x57ef96['id']]['updateRealtime']();}}return _0x392214['chatQueues'];};};Realtime[_0xaa41('0x16')][_0xaa41('0x20')]=function(){var _0x534a85=this;return function(_0x392b5d){if(_0x392b5d){freeIsNotKey(_0x392b5d,_0x534a85[_0xaa41('0xc')],'id');for(var _0x4e3b44=0x0,_0x5022fb={},_0x5c25fb={};_0x4e3b44<_0x392b5d[_0xaa41('0x19')];_0x4e3b44+=0x1){_0x5022fb=_0x392b5d[_0x4e3b44];if(_[_0xaa41('0x1a')](_0x534a85[_0xaa41('0xc')][_0x5022fb['id']])){_0x534a85[_0xaa41('0xc')][_0x5022fb['id']]=new SmsQueue(_0x5022fb);}else{_0x534a85['mergeFromDatabase'](_0x534a85[_0xaa41('0xc')][_0x5022fb['id']],_0x5022fb);}_0x534a85[_0xaa41('0xc')][_0x5022fb['id']][_0xaa41('0x21')]();_0x534a85['smsQueues'][_0x5022fb['id']][_0xaa41('0x22')]();}}return _0x534a85[_0xaa41('0xc')];};};Realtime[_0xaa41('0x16')]['initMailQueues']=function(){var _0x252c62=this;return function(_0x374117){if(_0x374117){freeIsNotKey(_0x374117,_0x252c62['mailQueues'],'id');for(var _0x23eb50=0x0,_0x13b6d4={},_0x2298ed={};_0x23eb50<_0x374117['length'];_0x23eb50+=0x1){_0x13b6d4=_0x374117[_0x23eb50];if(_[_0xaa41('0x1a')](_0x252c62['mailQueues'][_0x13b6d4['id']])){_0x252c62[_0xaa41('0xd')][_0x13b6d4['id']]=new MailQueue(_0x13b6d4);}else{_0x252c62[_0xaa41('0x17')](_0x252c62[_0xaa41('0xd')][_0x13b6d4['id']],_0x13b6d4);}_0x252c62['mailQueues'][_0x13b6d4['id']]['updateRouting']();_0x252c62['mailQueues'][_0x13b6d4['id']][_0xaa41('0x22')]();}}return _0x252c62[_0xaa41('0xd')];};};Realtime[_0xaa41('0x16')][_0xaa41('0x23')]=function(){var _0x4fbb92=this;return function(_0x53a2e4){if(_0x53a2e4){freeIsNotKey(_0x53a2e4,_0x4fbb92[_0xaa41('0x24')],'id');for(var _0x5673c=0x0,_0x951e52={},_0x4e8d2e={};_0x5673c<_0x53a2e4[_0xaa41('0x19')];_0x5673c+=0x1){_0x951e52=_0x53a2e4[_0x5673c];if(_[_0xaa41('0x1a')](_0x4fbb92[_0xaa41('0x24')][_0x951e52['id']])){_0x4fbb92['faxQueues'][_0x951e52['id']]=new FaxQueue(_0x951e52);}else{_0x4fbb92[_0xaa41('0x17')](_0x4fbb92[_0xaa41('0x24')][_0x951e52['id']],_0x951e52);}_0x4fbb92[_0xaa41('0x24')][_0x951e52['id']][_0xaa41('0x21')]();_0x4fbb92['faxQueues'][_0x951e52['id']]['updateRealtime']();}}return _0x4fbb92[_0xaa41('0x24')];};};Realtime[_0xaa41('0x16')]['initWhatsappQueues']=function(){var _0x4101ab=this;return function(_0x563687){if(_0x563687){freeIsNotKey(_0x563687,_0x4101ab[_0xaa41('0xe')],'id');for(var _0x25f2df=0x0,_0x1a2d11={},_0x466eee={};_0x25f2df<_0x563687[_0xaa41('0x19')];_0x25f2df+=0x1){_0x1a2d11=_0x563687[_0x25f2df];if(_[_0xaa41('0x1a')](_0x4101ab[_0xaa41('0xe')][_0x1a2d11['id']])){_0x4101ab[_0xaa41('0xe')][_0x1a2d11['id']]=new WhatsappQueue(_0x1a2d11);}else{_0x4101ab['mergeFromDatabase'](_0x4101ab[_0xaa41('0xe')][_0x1a2d11['id']],_0x1a2d11);}_0x4101ab[_0xaa41('0xe')][_0x1a2d11['id']][_0xaa41('0x21')]();_0x4101ab[_0xaa41('0xe')][_0x1a2d11['id']][_0xaa41('0x22')]();}}return _0x4101ab[_0xaa41('0xe')];};};module['exports']=Realtime;