Built motion from commit 20b39a97.|2.6.29
[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 _0x0a17=['dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgTalktime','voice','request','Queues','error','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','getRealtimeQueues','concat','outbound','map','loggedIn','busy','originated','find','merge','pick','client','available','paused','waiting','loggedInDb','notInUse','onHold','ringing','talking','unknown','pTalking','message','statusMessage','dialMethod','Trunk','startPredictive','erlangCallToSecond'];(function(_0x7b1b6f,_0x17afb7){var _0x1ed949=function(_0x430abe){while(--_0x430abe){_0x7b1b6f['push'](_0x7b1b6f['shift']());}};_0x1ed949(++_0x17afb7);}(_0x0a17,0x1c8));var _0x70a1=function(_0xbc8b39,_0x46b710){_0xbc8b39=_0xbc8b39-0x0;var _0x3462df=_0x0a17[_0xbc8b39];return _0x3462df;};'use strict';var _=require('lodash');var jayson=require('jayson/promise');var util=require('util');var amiClient=jayson[_0x70a1('0x0')]['http']({'port':0x232a});var routingClient=jayson[_0x70a1('0x0')]['http']({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x70a1('0x1'),'loggedIn',_0x70a1('0x2'),_0x70a1('0x3')];var VOICE_QUEUE_ATTRIBUTES=['busy','inUse','invalid',_0x70a1('0x4'),_0x70a1('0x5'),_0x70a1('0x6'),_0x70a1('0x7'),'ringInUse',_0x70a1('0x8'),'unavailable',_0x70a1('0x9')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x70a1('0xa'),'originated',_0x70a1('0xb'),_0x70a1('0xc'),'dialActive',_0x70a1('0xd'),_0x70a1('0xe'),_0x70a1('0xf'),'startProgressive','erlangCalls',_0x70a1('0x10'),'erlangAbandonmentRate','erlangBusyFactor',_0x70a1('0x11'),_0x70a1('0x12'),_0x70a1('0x13'),_0x70a1('0x14'),'predictiveIntervalTotalCalls',_0x70a1('0x15'),_0x70a1('0x16'),_0x70a1('0x17'),'predictiveIntervalAvgHoldtime',_0x70a1('0x18')];function getRealtimeQueues(_0x387f28,_0x4bb277){var _0x49e430=_0x4bb277===_0x70a1('0x19')?amiClient:routingClient;return _0x49e430[_0x70a1('0x1a')](_['startCase'](_0x4bb277)+_0x70a1('0x1b'),_0x387f28)['then'](function(_0x40ec9f){if(_0x40ec9f[_0x70a1('0x1c')])throw new Error(util[_0x70a1('0x1d')](_0x70a1('0x1e'),_0x4bb277));return _0x40ec9f[_0x70a1('0x1f')];})[_0x70a1('0x20')](function(_0x1e5daf){throw _0x1e5daf;});}exports[_0x70a1('0x21')]=getRealtimeQueues;function initializeQueues(_0x42f305,_0x5cf6a5,_0x1ba244,_0x3cb21d){var _0x1e05f4=DEFAULT_QUEUE_ATTRIBUTES;if(_0x1ba244===_0x70a1('0x19')){if(_0x3cb21d==='inbound'){_0x1e05f4=_0x1e05f4[_0x70a1('0x22')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x3cb21d===_0x70a1('0x23')){_0x1e05f4=_0x1e05f4['concat'](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x42f305[_0x70a1('0x24')](function(_0x5e6c26){var _0x4af645=_0x5e6c26['get']({'plain':!![]});_0x4af645[_0x70a1('0x2')]=0x0;_0x4af645[_0x70a1('0x4')]=0x0;_0x4af645[_0x70a1('0x25')]=0x0;_0x4af645[_0x70a1('0x1')]=0x0;_0x4af645[_0x70a1('0x3')]=0x0;if(_0x1ba244===_0x70a1('0x19')){_0x4af645[_0x70a1('0x8')]=0x0;_0x4af645[_0x70a1('0x26')]=0x0;if(_0x3cb21d==='outbound'){_0x4af645[_0x70a1('0xa')]=0x0;_0x4af645[_0x70a1('0x27')]=0x0;}}var _0x1abb69=_[_0x70a1('0x28')](_0x5cf6a5,['id',_0x4af645['id']]);if(_0x1abb69){_[_0x70a1('0x29')](_0x4af645,_[_0x70a1('0x2a')](_0x1abb69,_0x1e05f4));}return _0x4af645;});}exports['initializeQueues']=initializeQueues;