7badd96bd595f76e3a265f742a70c48b40b5ee0a
[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 _0x7d24=['find','merge','pick','initializeQueues','lodash','jayson/promise','util','client','http','loggedIn','waiting','invalid','loggedInDb','notInUse','ringing','ringInUse','talking','unavailable','unknown','pTalking','originated','message','statusMessage','dialActive','dialMethod','startPredictive','startProgressive','erlangCalls','erlangCallToSecond','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalTotalCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalAvgTalktime','voice','startCase','then','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','getRealtimeQueues','concat','outbound','map','paused','busy'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0x7d24,0x184));var _0x47d2=function(_0xe944b7,_0x515d61){_0xe944b7=_0xe944b7-0x0;var _0x390063=_0x7d24[_0xe944b7];return _0x390063;};'use strict';var _=require(_0x47d2('0x0'));var jayson=require(_0x47d2('0x1'));var util=require(_0x47d2('0x2'));var amiClient=jayson[_0x47d2('0x3')][_0x47d2('0x4')]({'port':0x232a});var routingClient=jayson[_0x47d2('0x3')]['http']({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=['available',_0x47d2('0x5'),'paused',_0x47d2('0x6')];var VOICE_QUEUE_ATTRIBUTES=['busy','inUse',_0x47d2('0x7'),_0x47d2('0x8'),_0x47d2('0x9'),'onHold',_0x47d2('0xa'),_0x47d2('0xb'),_0x47d2('0xc'),_0x47d2('0xd'),_0x47d2('0xe')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x47d2('0xf'),_0x47d2('0x10'),_0x47d2('0x11'),_0x47d2('0x12'),_0x47d2('0x13'),_0x47d2('0x14'),'Trunk',_0x47d2('0x15'),_0x47d2('0x16'),_0x47d2('0x17'),_0x47d2('0x18'),'erlangAbandonmentRate',_0x47d2('0x19'),_0x47d2('0x1a'),_0x47d2('0x1b'),_0x47d2('0x1c'),'predictiveIntervalAvailable',_0x47d2('0x1d'),'predictiveIntervalAnsweredCalls',_0x47d2('0x1e'),'predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime',_0x47d2('0x1f')];function getRealtimeQueues(_0x150543,_0x10726b){var _0x5eb90=_0x10726b===_0x47d2('0x20')?amiClient:routingClient;return _0x5eb90['request'](_[_0x47d2('0x21')](_0x10726b)+'Queues',_0x150543)[_0x47d2('0x22')](function(_0x493934){if(_0x493934['error'])throw new Error(util['format'](_0x47d2('0x23'),_0x10726b));return _0x493934[_0x47d2('0x24')];})[_0x47d2('0x25')](function(_0x11a33c){throw _0x11a33c;});}exports[_0x47d2('0x26')]=getRealtimeQueues;function initializeQueues(_0x56cade,_0x197324,_0x517add,_0x483e54){var _0x2e6bf=DEFAULT_QUEUE_ATTRIBUTES;if(_0x517add==='voice'){if(_0x483e54==='inbound'){_0x2e6bf=_0x2e6bf[_0x47d2('0x27')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x483e54===_0x47d2('0x28')){_0x2e6bf=_0x2e6bf[_0x47d2('0x27')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x56cade[_0x47d2('0x29')](function(_0x243d53){var _0x290ac2=_0x243d53['get']({'plain':!![]});_0x290ac2[_0x47d2('0x2a')]=0x0;_0x290ac2['loggedInDb']=0x0;_0x290ac2['loggedIn']=0x0;_0x290ac2['available']=0x0;_0x290ac2['waiting']=0x0;if(_0x517add===_0x47d2('0x20')){_0x290ac2[_0x47d2('0xc')]=0x0;_0x290ac2[_0x47d2('0x2b')]=0x0;if(_0x483e54==='outbound'){_0x290ac2[_0x47d2('0xf')]=0x0;_0x290ac2[_0x47d2('0x10')]=0x0;}}var _0x1fb2d3=_[_0x47d2('0x2c')](_0x197324,['id',_0x290ac2['id']]);if(_0x1fb2d3){_[_0x47d2('0x2d')](_0x290ac2,_[_0x47d2('0x2e')](_0x1fb2d3,_0x2e6bf));}return _0x290ac2;});}exports[_0x47d2('0x2f')]=initializeQueues;