Built motion from commit b0a9a629.|2.6.33
[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 _0x13e0=['waiting','talking','outbound','find','merge','pick','lodash','jayson/promise','client','http','available','paused','busy','inUse','invalid','loggedInDb','onHold','ringing','pTalking','originated','message','statusMessage','dialActive','dialMethod','Trunk','startProgressive','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveIntervalMaxThreshold','predictiveIntervalAvailable','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgTalktime','voice','startCase','Queues','then','error','format','result','catch','getRealtimeQueues','concat','loggedIn'];(function(_0x50570c,_0x51597d){var _0x46e42a=function(_0x4edc83){while(--_0x4edc83){_0x50570c['push'](_0x50570c['shift']());}};_0x46e42a(++_0x51597d);}(_0x13e0,0x192));var _0x013e=function(_0x3c43a9,_0x50b5a5){_0x3c43a9=_0x3c43a9-0x0;var _0x24d156=_0x13e0[_0x3c43a9];return _0x24d156;};'use strict';var _=require(_0x013e('0x0'));var jayson=require(_0x013e('0x1'));var util=require('util');var amiClient=jayson[_0x013e('0x2')][_0x013e('0x3')]({'port':0x232a});var routingClient=jayson[_0x013e('0x2')][_0x013e('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x013e('0x4'),'loggedIn',_0x013e('0x5'),'waiting'];var VOICE_QUEUE_ATTRIBUTES=[_0x013e('0x6'),_0x013e('0x7'),_0x013e('0x8'),_0x013e('0x9'),'notInUse',_0x013e('0xa'),_0x013e('0xb'),'ringInUse','talking','unavailable','unknown'];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x013e('0xc'),_0x013e('0xd'),_0x013e('0xe'),_0x013e('0xf'),_0x013e('0x10'),_0x013e('0x11'),_0x013e('0x12'),'startPredictive',_0x013e('0x13'),'erlangCalls','erlangCallToSecond',_0x013e('0x14'),_0x013e('0x15'),'dialPredictiveInterval',_0x013e('0x16'),'dialPredictiveIntervalMinThreshold',_0x013e('0x17'),'predictiveIntervalTotalCalls',_0x013e('0x18'),'predictiveIntervalDroppedCallsTimeout',_0x013e('0x19'),'predictiveIntervalAvgHoldtime',_0x013e('0x1a')];function getRealtimeQueues(_0x1f091c,_0x1986e3){var _0x3ebb72=_0x1986e3===_0x013e('0x1b')?amiClient:routingClient;return _0x3ebb72['request'](_[_0x013e('0x1c')](_0x1986e3)+_0x013e('0x1d'),_0x1f091c)[_0x013e('0x1e')](function(_0x573a01){if(_0x573a01[_0x013e('0x1f')])throw new Error(util[_0x013e('0x20')]('Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues',_0x1986e3));return _0x573a01[_0x013e('0x21')];})[_0x013e('0x22')](function(_0x2c575f){throw _0x2c575f;});}exports[_0x013e('0x23')]=getRealtimeQueues;function initializeQueues(_0x142f74,_0x1e9296,_0x344386,_0x10b843){var _0x10d251=DEFAULT_QUEUE_ATTRIBUTES;if(_0x344386===_0x013e('0x1b')){if(_0x10b843==='inbound'){_0x10d251=_0x10d251[_0x013e('0x24')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x10b843==='outbound'){_0x10d251=_0x10d251[_0x013e('0x24')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x142f74['map'](function(_0x3bcd94){var _0x5ebe6d=_0x3bcd94['get']({'plain':!![]});_0x5ebe6d[_0x013e('0x5')]=0x0;_0x5ebe6d[_0x013e('0x9')]=0x0;_0x5ebe6d[_0x013e('0x25')]=0x0;_0x5ebe6d['available']=0x0;_0x5ebe6d[_0x013e('0x26')]=0x0;if(_0x344386===_0x013e('0x1b')){_0x5ebe6d[_0x013e('0x27')]=0x0;_0x5ebe6d['busy']=0x0;if(_0x10b843===_0x013e('0x28')){_0x5ebe6d[_0x013e('0xc')]=0x0;_0x5ebe6d['originated']=0x0;}}var _0x4df98d=_[_0x013e('0x29')](_0x1e9296,['id',_0x5ebe6d['id']]);if(_0x4df98d){_[_0x013e('0x2a')](_0x5ebe6d,_[_0x013e('0x2b')](_0x4df98d,_0x10d251));}return _0x5ebe6d;});}exports['initializeQueues']=initializeQueues;