7980ac24f47d08bb5c1b9e703e91b3a85e980586
[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 _0xa6d1=['loggedInDb','notInUse','unavailable','unknown','pTalking','originated','statusMessage','dialActive','dialMethod','Trunk','startPredictive','startProgressive','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','request','startCase','Queues','then','error','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','getRealtimeQueues','concat','map','get','talking','outbound','find','merge','pick','initializeQueues','lodash','jayson/promise','client','http','available','loggedIn','paused','waiting','inUse'];(function(_0x2a2117,_0x2b02b6){var _0x1daf90=function(_0x34385a){while(--_0x34385a){_0x2a2117['push'](_0x2a2117['shift']());}};_0x1daf90(++_0x2b02b6);}(_0xa6d1,0x1a7));var _0x1a6d=function(_0x52ff0a,_0x44590f){_0x52ff0a=_0x52ff0a-0x0;var _0x3f5b6a=_0xa6d1[_0x52ff0a];return _0x3f5b6a;};'use strict';var _=require(_0x1a6d('0x0'));var jayson=require(_0x1a6d('0x1'));var util=require('util');var amiClient=jayson[_0x1a6d('0x2')][_0x1a6d('0x3')]({'port':0x232a});var routingClient=jayson[_0x1a6d('0x2')][_0x1a6d('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x1a6d('0x4'),_0x1a6d('0x5'),_0x1a6d('0x6'),_0x1a6d('0x7')];var VOICE_QUEUE_ATTRIBUTES=['busy',_0x1a6d('0x8'),'invalid',_0x1a6d('0x9'),_0x1a6d('0xa'),'onHold','ringing','ringInUse','talking',_0x1a6d('0xb'),_0x1a6d('0xc')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x1a6d('0xd'),_0x1a6d('0xe'),'message',_0x1a6d('0xf'),_0x1a6d('0x10'),_0x1a6d('0x11'),_0x1a6d('0x12'),_0x1a6d('0x13'),_0x1a6d('0x14'),_0x1a6d('0x15'),_0x1a6d('0x16'),_0x1a6d('0x17'),_0x1a6d('0x18'),_0x1a6d('0x19'),_0x1a6d('0x1a'),_0x1a6d('0x1b'),'predictiveIntervalAvailable',_0x1a6d('0x1c'),_0x1a6d('0x1d'),_0x1a6d('0x1e'),_0x1a6d('0x1f'),_0x1a6d('0x20'),_0x1a6d('0x21')];function getRealtimeQueues(_0x38c738,_0x266062){var _0x565728=_0x266062===_0x1a6d('0x22')?amiClient:routingClient;return _0x565728[_0x1a6d('0x23')](_[_0x1a6d('0x24')](_0x266062)+_0x1a6d('0x25'),_0x38c738)[_0x1a6d('0x26')](function(_0x4ae0f2){if(_0x4ae0f2[_0x1a6d('0x27')])throw new Error(util[_0x1a6d('0x28')](_0x1a6d('0x29'),_0x266062));return _0x4ae0f2[_0x1a6d('0x2a')];})[_0x1a6d('0x2b')](function(_0x4835b7){throw _0x4835b7;});}exports[_0x1a6d('0x2c')]=getRealtimeQueues;function initializeQueues(_0x4cad87,_0x31ecf6,_0x4b0688,_0x25514b){var _0x35c847=DEFAULT_QUEUE_ATTRIBUTES;if(_0x4b0688===_0x1a6d('0x22')){if(_0x25514b==='inbound'){_0x35c847=_0x35c847[_0x1a6d('0x2d')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x25514b==='outbound'){_0x35c847=_0x35c847[_0x1a6d('0x2d')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x4cad87[_0x1a6d('0x2e')](function(_0x29a291){var _0x1fc5f6=_0x29a291[_0x1a6d('0x2f')]({'plain':!![]});_0x1fc5f6[_0x1a6d('0x6')]=0x0;_0x1fc5f6[_0x1a6d('0x9')]=0x0;_0x1fc5f6[_0x1a6d('0x5')]=0x0;_0x1fc5f6['available']=0x0;_0x1fc5f6[_0x1a6d('0x7')]=0x0;if(_0x4b0688==='voice'){_0x1fc5f6[_0x1a6d('0x30')]=0x0;_0x1fc5f6['busy']=0x0;if(_0x25514b===_0x1a6d('0x31')){_0x1fc5f6[_0x1a6d('0xd')]=0x0;_0x1fc5f6[_0x1a6d('0xe')]=0x0;}}var _0x36e4ee=_[_0x1a6d('0x32')](_0x31ecf6,['id',_0x1fc5f6['id']]);if(_0x36e4ee){_[_0x1a6d('0x33')](_0x1fc5f6,_[_0x1a6d('0x34')](_0x36e4ee,_0x35c847));}return _0x1fc5f6;});}exports[_0x1a6d('0x35')]=initializeQueues;