70e7e2f203380a878ab52dd232a91574899503c1
[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 _0x9947=['ringInUse','talking','unavailable','originated','message','statusMessage','dialActive','dialMethod','startPredictive','startProgressive','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','startCase','then','error','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','getRealtimeQueues','inbound','concat','map','loggedIn','busy','pTalking','find','merge','initializeQueues','lodash','jayson/promise','util','client','http','available','paused','waiting','invalid','loggedInDb','notInUse','onHold'];(function(_0x29e6f7,_0x5f58d7){var _0xd87394=function(_0xa08773){while(--_0xa08773){_0x29e6f7['push'](_0x29e6f7['shift']());}};_0xd87394(++_0x5f58d7);}(_0x9947,0xf3));var _0x7994=function(_0x2545d0,_0x397e79){_0x2545d0=_0x2545d0-0x0;var _0x10111b=_0x9947[_0x2545d0];return _0x10111b;};'use strict';var _=require(_0x7994('0x0'));var jayson=require(_0x7994('0x1'));var util=require(_0x7994('0x2'));var amiClient=jayson[_0x7994('0x3')][_0x7994('0x4')]({'port':0x232a});var routingClient=jayson[_0x7994('0x3')][_0x7994('0x4')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x7994('0x5'),'loggedIn',_0x7994('0x6'),_0x7994('0x7')];var VOICE_QUEUE_ATTRIBUTES=['busy','inUse',_0x7994('0x8'),_0x7994('0x9'),_0x7994('0xa'),_0x7994('0xb'),'ringing',_0x7994('0xc'),_0x7994('0xd'),_0x7994('0xe'),'unknown'];var OUTBOUND_QUEUE_ATTRIBUTES=['pTalking',_0x7994('0xf'),_0x7994('0x10'),_0x7994('0x11'),_0x7994('0x12'),_0x7994('0x13'),'Trunk',_0x7994('0x14'),_0x7994('0x15'),_0x7994('0x16'),_0x7994('0x17'),_0x7994('0x18'),_0x7994('0x19'),'dialPredictiveInterval',_0x7994('0x1a'),_0x7994('0x1b'),_0x7994('0x1c'),_0x7994('0x1d'),_0x7994('0x1e'),'predictiveIntervalDroppedCallsTimeout',_0x7994('0x1f'),_0x7994('0x20'),_0x7994('0x21')];function getRealtimeQueues(_0x565522,_0x599054){var _0x5ce314=_0x599054===_0x7994('0x22')?amiClient:routingClient;return _0x5ce314['request'](_[_0x7994('0x23')](_0x599054)+'Queues',_0x565522)[_0x7994('0x24')](function(_0x9a3484){if(_0x9a3484[_0x7994('0x25')])throw new Error(util['format'](_0x7994('0x26'),_0x599054));return _0x9a3484[_0x7994('0x27')];})[_0x7994('0x28')](function(_0x177c3e){throw _0x177c3e;});}exports[_0x7994('0x29')]=getRealtimeQueues;function initializeQueues(_0x24bc61,_0x262a62,_0x1a303a,_0x5690d4){var _0x3bbf93=DEFAULT_QUEUE_ATTRIBUTES;if(_0x1a303a===_0x7994('0x22')){if(_0x5690d4===_0x7994('0x2a')){_0x3bbf93=_0x3bbf93[_0x7994('0x2b')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x5690d4==='outbound'){_0x3bbf93=_0x3bbf93['concat'](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x24bc61[_0x7994('0x2c')](function(_0x36764b){var _0x23c02d=_0x36764b['get']({'plain':!![]});_0x23c02d['paused']=0x0;_0x23c02d[_0x7994('0x9')]=0x0;_0x23c02d[_0x7994('0x2d')]=0x0;_0x23c02d[_0x7994('0x5')]=0x0;_0x23c02d[_0x7994('0x7')]=0x0;if(_0x1a303a==='voice'){_0x23c02d[_0x7994('0xd')]=0x0;_0x23c02d[_0x7994('0x2e')]=0x0;if(_0x5690d4==='outbound'){_0x23c02d[_0x7994('0x2f')]=0x0;_0x23c02d[_0x7994('0xf')]=0x0;}}var _0x32021b=_[_0x7994('0x30')](_0x262a62,['id',_0x23c02d['id']]);if(_0x32021b){_[_0x7994('0x31')](_0x23c02d,_['pick'](_0x32021b,_0x3bbf93));}return _0x23c02d;});}exports[_0x7994('0x32')]=initializeQueues;