c44e4a3e923e8327be0761a2218967b38dcf25ce
[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 _0x0742=['result','catch','voice','inbound','get','outbound','originated','find','pick','initializeQueues','lodash','util','client','http','available','loggedIn','paused','waiting','busy','invalid','loggedInDb','notInUse','onHold','ringing','ringInUse','talking','unavailable','unknown','pTalking','message','dialMethod','startPredictive','startProgressive','erlangCalls','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','request','Queues','then','error','format'];(function(_0x3e5249,_0xd46921){var _0x20a888=function(_0x98a972){while(--_0x98a972){_0x3e5249['push'](_0x3e5249['shift']());}};_0x20a888(++_0xd46921);}(_0x0742,0x1cc));var _0x2074=function(_0xccc0d4,_0x2f6bf7){_0xccc0d4=_0xccc0d4-0x0;var _0x27a653=_0x0742[_0xccc0d4];return _0x27a653;};'use strict';var _=require(_0x2074('0x0'));var jayson=require('jayson/promise');var util=require(_0x2074('0x1'));var amiClient=jayson[_0x2074('0x2')][_0x2074('0x3')]({'port':0x232a});var routingClient=jayson[_0x2074('0x2')][_0x2074('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x2074('0x4'),_0x2074('0x5'),_0x2074('0x6'),_0x2074('0x7')];var VOICE_QUEUE_ATTRIBUTES=[_0x2074('0x8'),'inUse',_0x2074('0x9'),_0x2074('0xa'),_0x2074('0xb'),_0x2074('0xc'),_0x2074('0xd'),_0x2074('0xe'),_0x2074('0xf'),_0x2074('0x10'),_0x2074('0x11')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x2074('0x12'),'originated',_0x2074('0x13'),'statusMessage','dialActive',_0x2074('0x14'),'Trunk',_0x2074('0x15'),_0x2074('0x16'),_0x2074('0x17'),'erlangCallToSecond',_0x2074('0x18'),_0x2074('0x19'),_0x2074('0x1a'),_0x2074('0x1b'),_0x2074('0x1c'),_0x2074('0x1d'),'predictiveIntervalTotalCalls',_0x2074('0x1e'),_0x2074('0x1f'),_0x2074('0x20'),_0x2074('0x21'),_0x2074('0x22')];function getRealtimeQueues(_0x14ece6,_0x134db7){var _0x37b279=_0x134db7==='voice'?amiClient:routingClient;return _0x37b279[_0x2074('0x23')](_['startCase'](_0x134db7)+_0x2074('0x24'),_0x14ece6)[_0x2074('0x25')](function(_0x3480f9){if(_0x3480f9[_0x2074('0x26')])throw new Error(util[_0x2074('0x27')]('Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues',_0x134db7));return _0x3480f9[_0x2074('0x28')];})[_0x2074('0x29')](function(_0x19ea3f){throw _0x19ea3f;});}exports['getRealtimeQueues']=getRealtimeQueues;function initializeQueues(_0x314b57,_0x26856d,_0x1a351c,_0x47e70d){var _0x551747=DEFAULT_QUEUE_ATTRIBUTES;if(_0x1a351c===_0x2074('0x2a')){if(_0x47e70d===_0x2074('0x2b')){_0x551747=_0x551747['concat'](VOICE_QUEUE_ATTRIBUTES);}else if(_0x47e70d==='outbound'){_0x551747=_0x551747['concat'](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x314b57['map'](function(_0x5e5f5b){var _0x41c95d=_0x5e5f5b[_0x2074('0x2c')]({'plain':!![]});_0x41c95d[_0x2074('0x6')]=0x0;_0x41c95d['loggedInDb']=0x0;_0x41c95d[_0x2074('0x5')]=0x0;_0x41c95d[_0x2074('0x4')]=0x0;_0x41c95d[_0x2074('0x7')]=0x0;if(_0x1a351c===_0x2074('0x2a')){_0x41c95d[_0x2074('0xf')]=0x0;_0x41c95d[_0x2074('0x8')]=0x0;if(_0x47e70d===_0x2074('0x2d')){_0x41c95d[_0x2074('0x12')]=0x0;_0x41c95d[_0x2074('0x2e')]=0x0;}}var _0xb2632e=_[_0x2074('0x2f')](_0x26856d,['id',_0x41c95d['id']]);if(_0xb2632e){_['merge'](_0x41c95d,_[_0x2074('0x30')](_0xb2632e,_0x551747));}return _0x41c95d;});}exports[_0x2074('0x31')]=initializeQueues;