9eada8e3a389cf1d0525d3205110009659b0f531
[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 _0x7557=['dialMethod','Trunk','startPredictive','erlangCalls','erlangAbandonmentRate','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','Queues','format','result','catch','getRealtimeQueues','inbound','concat','outbound','map','get','paused','originated','find','merge','pick','initializeQueues','lodash','util','http','client','available','loggedIn','waiting','busy','inUse','invalid','loggedInDb','ringing','ringInUse','talking','unavailable','unknown','pTalking','message','statusMessage','dialActive'];(function(_0x46bca3,_0x800469){var _0x24d603=function(_0xeaf3fc){while(--_0xeaf3fc){_0x46bca3['push'](_0x46bca3['shift']());}};_0x24d603(++_0x800469);}(_0x7557,0xe6));var _0x7755=function(_0x565ba4,_0x47ca03){_0x565ba4=_0x565ba4-0x0;var _0x5ddf0e=_0x7557[_0x565ba4];return _0x5ddf0e;};'use strict';var _=require(_0x7755('0x0'));var jayson=require('jayson/promise');var util=require(_0x7755('0x1'));var amiClient=jayson['client'][_0x7755('0x2')]({'port':0x232a});var routingClient=jayson[_0x7755('0x3')][_0x7755('0x2')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x7755('0x4'),_0x7755('0x5'),'paused',_0x7755('0x6')];var VOICE_QUEUE_ATTRIBUTES=[_0x7755('0x7'),_0x7755('0x8'),_0x7755('0x9'),_0x7755('0xa'),'notInUse','onHold',_0x7755('0xb'),_0x7755('0xc'),_0x7755('0xd'),_0x7755('0xe'),_0x7755('0xf')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x7755('0x10'),'originated',_0x7755('0x11'),_0x7755('0x12'),_0x7755('0x13'),_0x7755('0x14'),_0x7755('0x15'),_0x7755('0x16'),'startProgressive',_0x7755('0x17'),'erlangCallToSecond',_0x7755('0x18'),'erlangBusyFactor','dialPredictiveInterval',_0x7755('0x19'),_0x7755('0x1a'),_0x7755('0x1b'),_0x7755('0x1c'),_0x7755('0x1d'),'predictiveIntervalDroppedCallsTimeout',_0x7755('0x1e'),_0x7755('0x1f'),_0x7755('0x20')];function getRealtimeQueues(_0x1f1c5a,_0x223b93){var _0x4955f7=_0x223b93===_0x7755('0x21')?amiClient:routingClient;return _0x4955f7['request'](_['startCase'](_0x223b93)+_0x7755('0x22'),_0x1f1c5a)['then'](function(_0x3398d0){if(_0x3398d0['error'])throw new Error(util[_0x7755('0x23')]('Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues',_0x223b93));return _0x3398d0[_0x7755('0x24')];})[_0x7755('0x25')](function(_0x1c7e6c){throw _0x1c7e6c;});}exports[_0x7755('0x26')]=getRealtimeQueues;function initializeQueues(_0x12353f,_0x3323d0,_0x76b192,_0x306f37){var _0x464337=DEFAULT_QUEUE_ATTRIBUTES;if(_0x76b192===_0x7755('0x21')){if(_0x306f37===_0x7755('0x27')){_0x464337=_0x464337[_0x7755('0x28')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x306f37===_0x7755('0x29')){_0x464337=_0x464337['concat'](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x12353f[_0x7755('0x2a')](function(_0x8c28cf){var _0x102dcc=_0x8c28cf[_0x7755('0x2b')]({'plain':!![]});_0x102dcc[_0x7755('0x2c')]=0x0;_0x102dcc[_0x7755('0xa')]=0x0;_0x102dcc[_0x7755('0x5')]=0x0;_0x102dcc[_0x7755('0x4')]=0x0;_0x102dcc[_0x7755('0x6')]=0x0;if(_0x76b192===_0x7755('0x21')){_0x102dcc[_0x7755('0xd')]=0x0;_0x102dcc['busy']=0x0;if(_0x306f37==='outbound'){_0x102dcc[_0x7755('0x10')]=0x0;_0x102dcc[_0x7755('0x2d')]=0x0;}}var _0x2d0182=_[_0x7755('0x2e')](_0x3323d0,['id',_0x102dcc['id']]);if(_0x2d0182){_[_0x7755('0x2f')](_0x102dcc,_[_0x7755('0x30')](_0x2d0182,_0x464337));}return _0x102dcc;});}exports[_0x7755('0x31')]=initializeQueues;