254911e2075499ee9df21481b76384c4855eda8a
[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 _0xc5de=['erlangCalls','erlangCallToSecond','erlangBusyFactor','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','voice','request','startCase','then','error','format','result','catch','concat','outbound','get','loggedIn','available','busy','merge','pick','initializeQueues','jayson/promise','util','client','http','paused','waiting','inUse','invalid','loggedInDb','notInUse','onHold','talking','unavailable','unknown','pTalking','originated','statusMessage','dialMethod','startPredictive','startProgressive'];(function(_0x58734a,_0x300972){var _0x1f692e=function(_0x1ea701){while(--_0x1ea701){_0x58734a['push'](_0x58734a['shift']());}};_0x1f692e(++_0x300972);}(_0xc5de,0xd7));var _0xec5d=function(_0x22656e,_0x1163dc){_0x22656e=_0x22656e-0x0;var _0x3e4255=_0xc5de[_0x22656e];return _0x3e4255;};'use strict';var _=require('lodash');var jayson=require(_0xec5d('0x0'));var util=require(_0xec5d('0x1'));var amiClient=jayson[_0xec5d('0x2')]['http']({'port':0x232a});var routingClient=jayson[_0xec5d('0x2')][_0xec5d('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=['available','loggedIn',_0xec5d('0x4'),_0xec5d('0x5')];var VOICE_QUEUE_ATTRIBUTES=['busy',_0xec5d('0x6'),_0xec5d('0x7'),_0xec5d('0x8'),_0xec5d('0x9'),_0xec5d('0xa'),'ringing','ringInUse',_0xec5d('0xb'),_0xec5d('0xc'),_0xec5d('0xd')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0xec5d('0xe'),_0xec5d('0xf'),'message',_0xec5d('0x10'),'dialActive',_0xec5d('0x11'),'Trunk',_0xec5d('0x12'),_0xec5d('0x13'),_0xec5d('0x14'),_0xec5d('0x15'),'erlangAbandonmentRate',_0xec5d('0x16'),'dialPredictiveInterval',_0xec5d('0x17'),_0xec5d('0x18'),'predictiveIntervalAvailable',_0xec5d('0x19'),_0xec5d('0x1a'),_0xec5d('0x1b'),_0xec5d('0x1c'),_0xec5d('0x1d'),'predictiveIntervalAvgTalktime'];function getRealtimeQueues(_0x23063c,_0x35cf56){var _0x386b2c=_0x35cf56===_0xec5d('0x1e')?amiClient:routingClient;return _0x386b2c[_0xec5d('0x1f')](_[_0xec5d('0x20')](_0x35cf56)+'Queues',_0x23063c)[_0xec5d('0x21')](function(_0x48dd78){if(_0x48dd78[_0xec5d('0x22')])throw new Error(util[_0xec5d('0x23')]('Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues',_0x35cf56));return _0x48dd78[_0xec5d('0x24')];})[_0xec5d('0x25')](function(_0x2422f9){throw _0x2422f9;});}exports['getRealtimeQueues']=getRealtimeQueues;function initializeQueues(_0xf7a28f,_0x3e0516,_0x13b7ff,_0x7fe89e){var _0x1dc336=DEFAULT_QUEUE_ATTRIBUTES;if(_0x13b7ff==='voice'){if(_0x7fe89e==='inbound'){_0x1dc336=_0x1dc336[_0xec5d('0x26')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x7fe89e===_0xec5d('0x27')){_0x1dc336=_0x1dc336[_0xec5d('0x26')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0xf7a28f['map'](function(_0x26fd05){var _0x4c6425=_0x26fd05[_0xec5d('0x28')]({'plain':!![]});_0x4c6425[_0xec5d('0x4')]=0x0;_0x4c6425[_0xec5d('0x8')]=0x0;_0x4c6425[_0xec5d('0x29')]=0x0;_0x4c6425[_0xec5d('0x2a')]=0x0;_0x4c6425[_0xec5d('0x5')]=0x0;if(_0x13b7ff===_0xec5d('0x1e')){_0x4c6425[_0xec5d('0xb')]=0x0;_0x4c6425[_0xec5d('0x2b')]=0x0;if(_0x7fe89e===_0xec5d('0x27')){_0x4c6425[_0xec5d('0xe')]=0x0;_0x4c6425[_0xec5d('0xf')]=0x0;}}var _0x5058fa=_['find'](_0x3e0516,['id',_0x4c6425['id']]);if(_0x5058fa){_[_0xec5d('0x2c')](_0x4c6425,_[_0xec5d('0x2d')](_0x5058fa,_0x1dc336));}return _0x4c6425;});}exports[_0xec5d('0x2e')]=initializeQueues;