Built motion from commit c738b9ac.|2.6.25
[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 _0x97d8=['predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','startCase','Queues','then','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','getRealtimeQueues','inbound','concat','map','get','paused','initializeQueues','client','http','available','loggedIn','waiting','busy','inUse','invalid','loggedInDb','notInUse','talking','unavailable','unknown','pTalking','originated','message','dialActive','dialMethod','Trunk','startPredictive','erlangCalls','erlangCallToSecond','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls'];(function(_0x595add,_0x15feb9){var _0x52eb1a=function(_0x32fcec){while(--_0x32fcec){_0x595add['push'](_0x595add['shift']());}};_0x52eb1a(++_0x15feb9);}(_0x97d8,0x1e8));var _0x897d=function(_0xd454ca,_0x5d79b8){_0xd454ca=_0xd454ca-0x0;var _0x27d6b7=_0x97d8[_0xd454ca];return _0x27d6b7;};'use strict';var _=require('lodash');var jayson=require('jayson/promise');var util=require('util');var amiClient=jayson[_0x897d('0x0')][_0x897d('0x1')]({'port':0x232a});var routingClient=jayson[_0x897d('0x0')][_0x897d('0x1')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x897d('0x2'),_0x897d('0x3'),'paused',_0x897d('0x4')];var VOICE_QUEUE_ATTRIBUTES=[_0x897d('0x5'),_0x897d('0x6'),_0x897d('0x7'),_0x897d('0x8'),_0x897d('0x9'),'onHold','ringing','ringInUse',_0x897d('0xa'),_0x897d('0xb'),_0x897d('0xc')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x897d('0xd'),_0x897d('0xe'),_0x897d('0xf'),'statusMessage',_0x897d('0x10'),_0x897d('0x11'),_0x897d('0x12'),_0x897d('0x13'),'startProgressive',_0x897d('0x14'),_0x897d('0x15'),'erlangAbandonmentRate',_0x897d('0x16'),_0x897d('0x17'),_0x897d('0x18'),_0x897d('0x19'),_0x897d('0x1a'),_0x897d('0x1b'),_0x897d('0x1c'),_0x897d('0x1d'),_0x897d('0x1e'),_0x897d('0x1f'),_0x897d('0x20')];function getRealtimeQueues(_0x2a04f7,_0x39cdc0){var _0x1acea7=_0x39cdc0===_0x897d('0x21')?amiClient:routingClient;return _0x1acea7['request'](_[_0x897d('0x22')](_0x39cdc0)+_0x897d('0x23'),_0x2a04f7)[_0x897d('0x24')](function(_0x162914){if(_0x162914['error'])throw new Error(util[_0x897d('0x25')](_0x897d('0x26'),_0x39cdc0));return _0x162914[_0x897d('0x27')];})['catch'](function(_0x4403ce){throw _0x4403ce;});}exports[_0x897d('0x28')]=getRealtimeQueues;function initializeQueues(_0x44e59c,_0x3d9338,_0x277ee9,_0x1ef889){var _0x41c7f1=DEFAULT_QUEUE_ATTRIBUTES;if(_0x277ee9===_0x897d('0x21')){if(_0x1ef889===_0x897d('0x29')){_0x41c7f1=_0x41c7f1[_0x897d('0x2a')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x1ef889==='outbound'){_0x41c7f1=_0x41c7f1['concat'](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x44e59c[_0x897d('0x2b')](function(_0x2106bf){var _0x40ceb1=_0x2106bf[_0x897d('0x2c')]({'plain':!![]});_0x40ceb1[_0x897d('0x2d')]=0x0;_0x40ceb1[_0x897d('0x8')]=0x0;_0x40ceb1[_0x897d('0x3')]=0x0;_0x40ceb1[_0x897d('0x2')]=0x0;_0x40ceb1['waiting']=0x0;if(_0x277ee9===_0x897d('0x21')){_0x40ceb1[_0x897d('0xa')]=0x0;_0x40ceb1[_0x897d('0x5')]=0x0;if(_0x1ef889==='outbound'){_0x40ceb1['pTalking']=0x0;_0x40ceb1[_0x897d('0xe')]=0x0;}}var _0x2a58c9=_['find'](_0x3d9338,['id',_0x40ceb1['id']]);if(_0x2a58c9){_['merge'](_0x40ceb1,_['pick'](_0x2a58c9,_0x41c7f1));}return _0x40ceb1;});}exports[_0x897d('0x2e')]=initializeQueues;