957efdfe50190dbb93cd2323fe4cd8985d198b99
[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 _0x9fd0=['client','http','loggedIn','paused','waiting','inUse','invalid','loggedInDb','onHold','talking','unknown','originated','message','statusMessage','dialMethod','startPredictive','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','request','Queues','then','error','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','inbound','outbound','concat','busy','find','merge','pick','initializeQueues','lodash','jayson/promise','util'];(function(_0xe93902,_0x2f628e){var _0x10b24f=function(_0x254d6b){while(--_0x254d6b){_0xe93902['push'](_0xe93902['shift']());}};_0x10b24f(++_0x2f628e);}(_0x9fd0,0xbd));var _0x09fd=function(_0x405754,_0x2f76c5){_0x405754=_0x405754-0x0;var _0x2a76f6=_0x9fd0[_0x405754];return _0x2a76f6;};'use strict';var _=require(_0x09fd('0x0'));var jayson=require(_0x09fd('0x1'));var util=require(_0x09fd('0x2'));var amiClient=jayson[_0x09fd('0x3')][_0x09fd('0x4')]({'port':0x232a});var routingClient=jayson[_0x09fd('0x3')][_0x09fd('0x4')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=['available',_0x09fd('0x5'),_0x09fd('0x6'),_0x09fd('0x7')];var VOICE_QUEUE_ATTRIBUTES=['busy',_0x09fd('0x8'),_0x09fd('0x9'),_0x09fd('0xa'),'notInUse',_0x09fd('0xb'),'ringing','ringInUse',_0x09fd('0xc'),'unavailable',_0x09fd('0xd')];var OUTBOUND_QUEUE_ATTRIBUTES=['pTalking',_0x09fd('0xe'),_0x09fd('0xf'),_0x09fd('0x10'),'dialActive',_0x09fd('0x11'),'Trunk',_0x09fd('0x12'),'startProgressive','erlangCalls',_0x09fd('0x13'),_0x09fd('0x14'),_0x09fd('0x15'),_0x09fd('0x16'),_0x09fd('0x17'),_0x09fd('0x18'),_0x09fd('0x19'),_0x09fd('0x1a'),_0x09fd('0x1b'),'predictiveIntervalDroppedCallsTimeout',_0x09fd('0x1c'),_0x09fd('0x1d'),_0x09fd('0x1e')];function getRealtimeQueues(_0x55fc31,_0x3ac800){var _0x1bea72=_0x3ac800===_0x09fd('0x1f')?amiClient:routingClient;return _0x1bea72[_0x09fd('0x20')](_['startCase'](_0x3ac800)+_0x09fd('0x21'),_0x55fc31)[_0x09fd('0x22')](function(_0xc19bbe){if(_0xc19bbe[_0x09fd('0x23')])throw new Error(util[_0x09fd('0x24')](_0x09fd('0x25'),_0x3ac800));return _0xc19bbe[_0x09fd('0x26')];})[_0x09fd('0x27')](function(_0x15c107){throw _0x15c107;});}exports['getRealtimeQueues']=getRealtimeQueues;function initializeQueues(_0x261b67,_0x4a4313,_0x21de2b,_0xc989ba){var _0x42b135=DEFAULT_QUEUE_ATTRIBUTES;if(_0x21de2b===_0x09fd('0x1f')){if(_0xc989ba===_0x09fd('0x28')){_0x42b135=_0x42b135['concat'](VOICE_QUEUE_ATTRIBUTES);}else if(_0xc989ba===_0x09fd('0x29')){_0x42b135=_0x42b135[_0x09fd('0x2a')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x261b67['map'](function(_0x5b07a8){var _0x4d6479=_0x5b07a8['get']({'plain':!![]});_0x4d6479[_0x09fd('0x6')]=0x0;_0x4d6479[_0x09fd('0xa')]=0x0;_0x4d6479['loggedIn']=0x0;_0x4d6479['available']=0x0;_0x4d6479[_0x09fd('0x7')]=0x0;if(_0x21de2b===_0x09fd('0x1f')){_0x4d6479[_0x09fd('0xc')]=0x0;_0x4d6479[_0x09fd('0x2b')]=0x0;if(_0xc989ba===_0x09fd('0x29')){_0x4d6479['pTalking']=0x0;_0x4d6479[_0x09fd('0xe')]=0x0;}}var _0x173902=_[_0x09fd('0x2c')](_0x4a4313,['id',_0x4d6479['id']]);if(_0x173902){_[_0x09fd('0x2d')](_0x4d6479,_[_0x09fd('0x2e')](_0x173902,_0x42b135));}return _0x4d6479;});}exports[_0x09fd('0x2f')]=initializeQueues;