037ea1ada68d11db2957691070c8fb2e76e44d2a
[motion2.git] / server / components / realtime / queues.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 _0x110c=['startProgressive','erlangCalls','erlangCallToSecond','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','request','startCase','Queues','error','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','getRealtimeQueues','inbound','concat','outbound','map','find','merge','pick','initializeQueues','lodash','jayson/promise','client','http','available','loggedIn','paused','waiting','busy','invalid','loggedInDb','onHold','ringing','talking','unknown','pTalking','originated','message','statusMessage','dialMethod','Trunk','startPredictive'];(function(_0x1e7d1b,_0x2f7928){var _0x344a5c=function(_0xfa4dc7){while(--_0xfa4dc7){_0x1e7d1b['push'](_0x1e7d1b['shift']());}};_0x344a5c(++_0x2f7928);}(_0x110c,0x1de));var _0xc110=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x110c[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0xc110('0x0'));var jayson=require(_0xc110('0x1'));var util=require('util');var amiClient=jayson[_0xc110('0x2')][_0xc110('0x3')]({'port':0x232a});var routingClient=jayson[_0xc110('0x2')][_0xc110('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0xc110('0x4'),_0xc110('0x5'),_0xc110('0x6'),_0xc110('0x7')];var VOICE_QUEUE_ATTRIBUTES=[_0xc110('0x8'),'inUse',_0xc110('0x9'),_0xc110('0xa'),'notInUse',_0xc110('0xb'),_0xc110('0xc'),'ringInUse',_0xc110('0xd'),'unavailable',_0xc110('0xe')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0xc110('0xf'),_0xc110('0x10'),_0xc110('0x11'),_0xc110('0x12'),'dialActive',_0xc110('0x13'),_0xc110('0x14'),_0xc110('0x15'),_0xc110('0x16'),_0xc110('0x17'),_0xc110('0x18'),'erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold',_0xc110('0x19'),_0xc110('0x1a'),_0xc110('0x1b'),_0xc110('0x1c'),_0xc110('0x1d'),_0xc110('0x1e'),_0xc110('0x1f')];function getRealtimeQueues(_0x5a34ea,_0x39c42f){var _0x5648c9=_0x39c42f===_0xc110('0x20')?amiClient:routingClient;return _0x5648c9[_0xc110('0x21')](_[_0xc110('0x22')](_0x39c42f)+_0xc110('0x23'),_0x5a34ea)['then'](function(_0xa2d027){if(_0xa2d027[_0xc110('0x24')])throw new Error(util[_0xc110('0x25')](_0xc110('0x26'),_0x39c42f));return _0xa2d027[_0xc110('0x27')];})[_0xc110('0x28')](function(_0x6423f4){throw _0x6423f4;});}exports[_0xc110('0x29')]=getRealtimeQueues;function initializeQueues(_0x4c06b6,_0x161c4d,_0x223822,_0x43faa6){var _0x32f518=DEFAULT_QUEUE_ATTRIBUTES;if(_0x223822===_0xc110('0x20')){if(_0x43faa6===_0xc110('0x2a')){_0x32f518=_0x32f518[_0xc110('0x2b')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x43faa6===_0xc110('0x2c')){_0x32f518=_0x32f518[_0xc110('0x2b')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x4c06b6[_0xc110('0x2d')](function(_0x81b3dc){var _0x3fed5e=_0x81b3dc['get']({'plain':!![]});_0x3fed5e[_0xc110('0x6')]=0x0;_0x3fed5e[_0xc110('0xa')]=0x0;_0x3fed5e[_0xc110('0x5')]=0x0;_0x3fed5e[_0xc110('0x4')]=0x0;_0x3fed5e['waiting']=0x0;if(_0x223822==='voice'){_0x3fed5e[_0xc110('0xd')]=0x0;_0x3fed5e[_0xc110('0x8')]=0x0;if(_0x43faa6===_0xc110('0x2c')){_0x3fed5e[_0xc110('0xf')]=0x0;_0x3fed5e['originated']=0x0;}}var _0xfba0e9=_[_0xc110('0x2e')](_0x161c4d,['id',_0x3fed5e['id']]);if(_0xfba0e9){_[_0xc110('0x2f')](_0x3fed5e,_[_0xc110('0x30')](_0xfba0e9,_0x32f518));}return _0x3fed5e;});}exports[_0xc110('0x31')]=initializeQueues;