6f41b885dbaffe4d43916889671185b345730123
[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 _0x92d4=['startPredictive','startProgressive','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalTotalCalls','predictiveIntervalDroppedCallsCallersExit','startCase','Queues','then','error','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','getRealtimeQueues','inbound','concat','outbound','map','get','waiting','voice','find','merge','pick','lodash','jayson/promise','http','client','available','loggedIn','paused','inUse','invalid','loggedInDb','onHold','ringing','ringInUse','talking','unavailable','unknown','originated','message','statusMessage','dialActive','Trunk'];(function(_0x410be8,_0x1b4d64){var _0x39a7af=function(_0x5d0153){while(--_0x5d0153){_0x410be8['push'](_0x410be8['shift']());}};_0x39a7af(++_0x1b4d64);}(_0x92d4,0x1d5));var _0x492d=function(_0x41fddf,_0x515090){_0x41fddf=_0x41fddf-0x0;var _0x362dad=_0x92d4[_0x41fddf];return _0x362dad;};'use strict';var _=require(_0x492d('0x0'));var jayson=require(_0x492d('0x1'));var util=require('util');var amiClient=jayson['client'][_0x492d('0x2')]({'port':0x232a});var routingClient=jayson[_0x492d('0x3')][_0x492d('0x2')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x492d('0x4'),_0x492d('0x5'),_0x492d('0x6'),'waiting'];var VOICE_QUEUE_ATTRIBUTES=['busy',_0x492d('0x7'),_0x492d('0x8'),_0x492d('0x9'),'notInUse',_0x492d('0xa'),_0x492d('0xb'),_0x492d('0xc'),_0x492d('0xd'),_0x492d('0xe'),_0x492d('0xf')];var OUTBOUND_QUEUE_ATTRIBUTES=['pTalking',_0x492d('0x10'),_0x492d('0x11'),_0x492d('0x12'),_0x492d('0x13'),'dialMethod',_0x492d('0x14'),_0x492d('0x15'),_0x492d('0x16'),_0x492d('0x17'),_0x492d('0x18'),_0x492d('0x19'),_0x492d('0x1a'),_0x492d('0x1b'),_0x492d('0x1c'),_0x492d('0x1d'),'predictiveIntervalAvailable',_0x492d('0x1e'),'predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout',_0x492d('0x1f'),'predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime'];function getRealtimeQueues(_0xdf1c72,_0x552926){var _0x52860d=_0x552926==='voice'?amiClient:routingClient;return _0x52860d['request'](_[_0x492d('0x20')](_0x552926)+_0x492d('0x21'),_0xdf1c72)[_0x492d('0x22')](function(_0x32f2e5){if(_0x32f2e5[_0x492d('0x23')])throw new Error(util[_0x492d('0x24')](_0x492d('0x25'),_0x552926));return _0x32f2e5['result'];})['catch'](function(_0x13dc7e){throw _0x13dc7e;});}exports[_0x492d('0x26')]=getRealtimeQueues;function initializeQueues(_0x451f56,_0x20872f,_0x4f035c,_0x5eb9fe){var _0x39f5e2=DEFAULT_QUEUE_ATTRIBUTES;if(_0x4f035c==='voice'){if(_0x5eb9fe===_0x492d('0x27')){_0x39f5e2=_0x39f5e2[_0x492d('0x28')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x5eb9fe===_0x492d('0x29')){_0x39f5e2=_0x39f5e2[_0x492d('0x28')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x451f56[_0x492d('0x2a')](function(_0x3305c9){var _0x589dbc=_0x3305c9[_0x492d('0x2b')]({'plain':!![]});_0x589dbc['paused']=0x0;_0x589dbc[_0x492d('0x9')]=0x0;_0x589dbc['loggedIn']=0x0;_0x589dbc[_0x492d('0x4')]=0x0;_0x589dbc[_0x492d('0x2c')]=0x0;if(_0x4f035c===_0x492d('0x2d')){_0x589dbc[_0x492d('0xd')]=0x0;_0x589dbc['busy']=0x0;if(_0x5eb9fe===_0x492d('0x29')){_0x589dbc['pTalking']=0x0;_0x589dbc[_0x492d('0x10')]=0x0;}}var _0x133aec=_[_0x492d('0x2e')](_0x20872f,['id',_0x589dbc['id']]);if(_0x133aec){_[_0x492d('0x2f')](_0x589dbc,_[_0x492d('0x30')](_0x133aec,_0x39f5e2));}return _0x589dbc;});}exports['initializeQueues']=initializeQueues;