Built motion from commit 10af8726.|2.6.34
[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 _0xf867=['Queues','error','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','getRealtimeQueues','inbound','outbound','concat','map','loggedIn','available','find','merge','pick','initializeQueues','jayson/promise','util','client','http','paused','waiting','busy','invalid','loggedInDb','onHold','ringing','talking','unavailable','unknown','pTalking','originated','message','dialActive','dialMethod','Trunk','startPredictive','startProgressive','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgTalktime','voice','startCase'];(function(_0x2168a3,_0x7bce5c){var _0x16db53=function(_0x6aaa19){while(--_0x6aaa19){_0x2168a3['push'](_0x2168a3['shift']());}};_0x16db53(++_0x7bce5c);}(_0xf867,0xaa));var _0x7f86=function(_0x552ccc,_0x15958b){_0x552ccc=_0x552ccc-0x0;var _0x30ba8e=_0xf867[_0x552ccc];return _0x30ba8e;};'use strict';var _=require('lodash');var jayson=require(_0x7f86('0x0'));var util=require(_0x7f86('0x1'));var amiClient=jayson[_0x7f86('0x2')][_0x7f86('0x3')]({'port':0x232a});var routingClient=jayson[_0x7f86('0x2')][_0x7f86('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=['available','loggedIn',_0x7f86('0x4'),_0x7f86('0x5')];var VOICE_QUEUE_ATTRIBUTES=[_0x7f86('0x6'),'inUse',_0x7f86('0x7'),_0x7f86('0x8'),'notInUse',_0x7f86('0x9'),_0x7f86('0xa'),'ringInUse',_0x7f86('0xb'),_0x7f86('0xc'),_0x7f86('0xd')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x7f86('0xe'),_0x7f86('0xf'),_0x7f86('0x10'),'statusMessage',_0x7f86('0x11'),_0x7f86('0x12'),_0x7f86('0x13'),_0x7f86('0x14'),_0x7f86('0x15'),'erlangCalls','erlangCallToSecond',_0x7f86('0x16'),_0x7f86('0x17'),_0x7f86('0x18'),'dialPredictiveIntervalMaxThreshold',_0x7f86('0x19'),_0x7f86('0x1a'),_0x7f86('0x1b'),_0x7f86('0x1c'),_0x7f86('0x1d'),_0x7f86('0x1e'),'predictiveIntervalAvgHoldtime',_0x7f86('0x1f')];function getRealtimeQueues(_0x4a6c87,_0x23fbec){var _0x4cc9ce=_0x23fbec===_0x7f86('0x20')?amiClient:routingClient;return _0x4cc9ce['request'](_[_0x7f86('0x21')](_0x23fbec)+_0x7f86('0x22'),_0x4a6c87)['then'](function(_0x5f28d8){if(_0x5f28d8[_0x7f86('0x23')])throw new Error(util[_0x7f86('0x24')](_0x7f86('0x25'),_0x23fbec));return _0x5f28d8[_0x7f86('0x26')];})[_0x7f86('0x27')](function(_0x1dfed0){throw _0x1dfed0;});}exports[_0x7f86('0x28')]=getRealtimeQueues;function initializeQueues(_0x5937db,_0x262edf,_0x2af4df,_0x1a4867){var _0x514218=DEFAULT_QUEUE_ATTRIBUTES;if(_0x2af4df===_0x7f86('0x20')){if(_0x1a4867===_0x7f86('0x29')){_0x514218=_0x514218['concat'](VOICE_QUEUE_ATTRIBUTES);}else if(_0x1a4867===_0x7f86('0x2a')){_0x514218=_0x514218[_0x7f86('0x2b')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x5937db[_0x7f86('0x2c')](function(_0x265e5a){var _0x4df04f=_0x265e5a['get']({'plain':!![]});_0x4df04f[_0x7f86('0x4')]=0x0;_0x4df04f[_0x7f86('0x8')]=0x0;_0x4df04f[_0x7f86('0x2d')]=0x0;_0x4df04f[_0x7f86('0x2e')]=0x0;_0x4df04f[_0x7f86('0x5')]=0x0;if(_0x2af4df===_0x7f86('0x20')){_0x4df04f[_0x7f86('0xb')]=0x0;_0x4df04f['busy']=0x0;if(_0x1a4867==='outbound'){_0x4df04f['pTalking']=0x0;_0x4df04f[_0x7f86('0xf')]=0x0;}}var _0x6a1001=_[_0x7f86('0x2f')](_0x262edf,['id',_0x4df04f['id']]);if(_0x6a1001){_[_0x7f86('0x30')](_0x4df04f,_[_0x7f86('0x31')](_0x6a1001,_0x514218));}return _0x4df04f;});}exports[_0x7f86('0x32')]=initializeQueues;