3ac693c65d101b5989520f2314da9a8c2dbfa28c
[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 _0xa880=['Queues','then','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','getRealtimeQueues','voice','inbound','concat','outbound','map','get','available','merge','pick','initializeQueues','lodash','jayson/promise','util','client','http','paused','waiting','inUse','invalid','onHold','ringing','talking','unknown','pTalking','originated','message','statusMessage','dialMethod','startProgressive','erlangCalls','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalTotalCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','request'];(function(_0x760e89,_0x51e2ab){var _0x3f8864=function(_0x1c8a16){while(--_0x1c8a16){_0x760e89['push'](_0x760e89['shift']());}};_0x3f8864(++_0x51e2ab);}(_0xa880,0x12b));var _0x0a88=function(_0x4a310d,_0x33322d){_0x4a310d=_0x4a310d-0x0;var _0x5eaf36=_0xa880[_0x4a310d];return _0x5eaf36;};'use strict';var _=require(_0x0a88('0x0'));var jayson=require(_0x0a88('0x1'));var util=require(_0x0a88('0x2'));var amiClient=jayson[_0x0a88('0x3')][_0x0a88('0x4')]({'port':0x232a});var routingClient=jayson[_0x0a88('0x3')][_0x0a88('0x4')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=['available','loggedIn',_0x0a88('0x5'),_0x0a88('0x6')];var VOICE_QUEUE_ATTRIBUTES=['busy',_0x0a88('0x7'),_0x0a88('0x8'),'loggedInDb','notInUse',_0x0a88('0x9'),_0x0a88('0xa'),'ringInUse',_0x0a88('0xb'),'unavailable',_0x0a88('0xc')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x0a88('0xd'),_0x0a88('0xe'),_0x0a88('0xf'),_0x0a88('0x10'),'dialActive',_0x0a88('0x11'),'Trunk','startPredictive',_0x0a88('0x12'),_0x0a88('0x13'),'erlangCallToSecond',_0x0a88('0x14'),_0x0a88('0x15'),_0x0a88('0x16'),_0x0a88('0x17'),_0x0a88('0x18'),'predictiveIntervalAvailable',_0x0a88('0x19'),'predictiveIntervalAnsweredCalls',_0x0a88('0x1a'),_0x0a88('0x1b'),_0x0a88('0x1c'),'predictiveIntervalAvgTalktime'];function getRealtimeQueues(_0x58b0fe,_0x2689bb){var _0x242ceb=_0x2689bb==='voice'?amiClient:routingClient;return _0x242ceb[_0x0a88('0x1d')](_['startCase'](_0x2689bb)+_0x0a88('0x1e'),_0x58b0fe)[_0x0a88('0x1f')](function(_0x112aaf){if(_0x112aaf['error'])throw new Error(util[_0x0a88('0x20')](_0x0a88('0x21'),_0x2689bb));return _0x112aaf[_0x0a88('0x22')];})[_0x0a88('0x23')](function(_0x4dafc8){throw _0x4dafc8;});}exports[_0x0a88('0x24')]=getRealtimeQueues;function initializeQueues(_0x5e32fc,_0x3f7235,_0x1a9d7e,_0x43c752){var _0x4d4410=DEFAULT_QUEUE_ATTRIBUTES;if(_0x1a9d7e===_0x0a88('0x25')){if(_0x43c752===_0x0a88('0x26')){_0x4d4410=_0x4d4410[_0x0a88('0x27')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x43c752===_0x0a88('0x28')){_0x4d4410=_0x4d4410['concat'](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x5e32fc[_0x0a88('0x29')](function(_0x1971a3){var _0x32bfae=_0x1971a3[_0x0a88('0x2a')]({'plain':!![]});_0x32bfae['paused']=0x0;_0x32bfae['loggedInDb']=0x0;_0x32bfae['loggedIn']=0x0;_0x32bfae[_0x0a88('0x2b')]=0x0;_0x32bfae[_0x0a88('0x6')]=0x0;if(_0x1a9d7e===_0x0a88('0x25')){_0x32bfae[_0x0a88('0xb')]=0x0;_0x32bfae['busy']=0x0;if(_0x43c752===_0x0a88('0x28')){_0x32bfae[_0x0a88('0xd')]=0x0;_0x32bfae[_0x0a88('0xe')]=0x0;}}var _0x32c82b=_['find'](_0x3f7235,['id',_0x32bfae['id']]);if(_0x32c82b){_[_0x0a88('0x2c')](_0x32bfae,_[_0x0a88('0x2d')](_0x32c82b,_0x4d4410));}return _0x32bfae;});}exports[_0x0a88('0x2e')]=initializeQueues;