3641a3af88541281002fb2aec447e9b32d4d0e58
[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 _0x11bd=['busy','inUse','invalid','loggedInDb','notInUse','onHold','talking','unavailable','pTalking','message','statusMessage','dialActive','Trunk','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','voice','startCase','Queues','then','error','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','catch','getRealtimeQueues','concat','outbound','map','available','originated','find','merge','pick','initializeQueues','jayson/promise','util','client','loggedIn','paused','waiting'];(function(_0x51020b,_0x38c2c7){var _0x371e47=function(_0x2a538f){while(--_0x2a538f){_0x51020b['push'](_0x51020b['shift']());}};_0x371e47(++_0x38c2c7);}(_0x11bd,0xba));var _0xd11b=function(_0x7bf8ec,_0x4b531d){_0x7bf8ec=_0x7bf8ec-0x0;var _0x40a911=_0x11bd[_0x7bf8ec];return _0x40a911;};'use strict';var _=require('lodash');var jayson=require(_0xd11b('0x0'));var util=require(_0xd11b('0x1'));var amiClient=jayson[_0xd11b('0x2')]['http']({'port':0x232a});var routingClient=jayson[_0xd11b('0x2')]['http']({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=['available',_0xd11b('0x3'),_0xd11b('0x4'),_0xd11b('0x5')];var VOICE_QUEUE_ATTRIBUTES=[_0xd11b('0x6'),_0xd11b('0x7'),_0xd11b('0x8'),_0xd11b('0x9'),_0xd11b('0xa'),_0xd11b('0xb'),'ringing','ringInUse',_0xd11b('0xc'),_0xd11b('0xd'),'unknown'];var OUTBOUND_QUEUE_ATTRIBUTES=[_0xd11b('0xe'),'originated',_0xd11b('0xf'),_0xd11b('0x10'),_0xd11b('0x11'),'dialMethod',_0xd11b('0x12'),'startPredictive','startProgressive',_0xd11b('0x13'),_0xd11b('0x14'),_0xd11b('0x15'),'erlangBusyFactor',_0xd11b('0x16'),_0xd11b('0x17'),_0xd11b('0x18'),_0xd11b('0x19'),_0xd11b('0x1a'),'predictiveIntervalAnsweredCalls',_0xd11b('0x1b'),_0xd11b('0x1c'),_0xd11b('0x1d'),'predictiveIntervalAvgTalktime'];function getRealtimeQueues(_0x2e9b6b,_0x2199f7){var _0x2c848f=_0x2199f7===_0xd11b('0x1e')?amiClient:routingClient;return _0x2c848f['request'](_[_0xd11b('0x1f')](_0x2199f7)+_0xd11b('0x20'),_0x2e9b6b)[_0xd11b('0x21')](function(_0x41fb49){if(_0x41fb49[_0xd11b('0x22')])throw new Error(util[_0xd11b('0x23')](_0xd11b('0x24'),_0x2199f7));return _0x41fb49['result'];})[_0xd11b('0x25')](function(_0x59afeb){throw _0x59afeb;});}exports[_0xd11b('0x26')]=getRealtimeQueues;function initializeQueues(_0x3c36d4,_0x4fc4d6,_0x8f8217,_0x345577){var _0x1930b0=DEFAULT_QUEUE_ATTRIBUTES;if(_0x8f8217==='voice'){if(_0x345577==='inbound'){_0x1930b0=_0x1930b0[_0xd11b('0x27')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x345577===_0xd11b('0x28')){_0x1930b0=_0x1930b0[_0xd11b('0x27')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x3c36d4[_0xd11b('0x29')](function(_0x416528){var _0x3cb7b0=_0x416528['get']({'plain':!![]});_0x3cb7b0[_0xd11b('0x4')]=0x0;_0x3cb7b0[_0xd11b('0x9')]=0x0;_0x3cb7b0[_0xd11b('0x3')]=0x0;_0x3cb7b0[_0xd11b('0x2a')]=0x0;_0x3cb7b0[_0xd11b('0x5')]=0x0;if(_0x8f8217===_0xd11b('0x1e')){_0x3cb7b0[_0xd11b('0xc')]=0x0;_0x3cb7b0[_0xd11b('0x6')]=0x0;if(_0x345577===_0xd11b('0x28')){_0x3cb7b0[_0xd11b('0xe')]=0x0;_0x3cb7b0[_0xd11b('0x2b')]=0x0;}}var _0x52929b=_[_0xd11b('0x2c')](_0x4fc4d6,['id',_0x3cb7b0['id']]);if(_0x52929b){_[_0xd11b('0x2d')](_0x3cb7b0,_[_0xd11b('0x2e')](_0x52929b,_0x1930b0));}return _0x3cb7b0;});}exports[_0xd11b('0x2f')]=initializeQueues;