Built motion from commit a679711e.|2.6.15
[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 _0x3f21=['initializeQueues','lodash','jayson/promise','util','client','http','available','loggedIn','paused','busy','inUse','invalid','loggedInDb','notInUse','onHold','ringing','ringInUse','talking','unavailable','unknown','pTalking','originated','statusMessage','dialActive','Trunk','startPredictive','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','startCase','Queues','then','error','result','concat','outbound','map','get','waiting','find','merge','pick'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3f21,0x174));var _0x13f2=function(_0xb9280f,_0x14f5f4){_0xb9280f=_0xb9280f-0x0;var _0x539e83=_0x3f21[_0xb9280f];return _0x539e83;};'use strict';var _=require(_0x13f2('0x0'));var jayson=require(_0x13f2('0x1'));var util=require(_0x13f2('0x2'));var amiClient=jayson[_0x13f2('0x3')]['http']({'port':0x232a});var routingClient=jayson['client'][_0x13f2('0x4')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x13f2('0x5'),_0x13f2('0x6'),_0x13f2('0x7'),'waiting'];var VOICE_QUEUE_ATTRIBUTES=[_0x13f2('0x8'),_0x13f2('0x9'),_0x13f2('0xa'),_0x13f2('0xb'),_0x13f2('0xc'),_0x13f2('0xd'),_0x13f2('0xe'),_0x13f2('0xf'),_0x13f2('0x10'),_0x13f2('0x11'),_0x13f2('0x12')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x13f2('0x13'),_0x13f2('0x14'),'message',_0x13f2('0x15'),_0x13f2('0x16'),'dialMethod',_0x13f2('0x17'),_0x13f2('0x18'),'startProgressive',_0x13f2('0x19'),_0x13f2('0x1a'),_0x13f2('0x1b'),_0x13f2('0x1c'),_0x13f2('0x1d'),'dialPredictiveIntervalMaxThreshold',_0x13f2('0x1e'),_0x13f2('0x1f'),_0x13f2('0x20'),_0x13f2('0x21'),_0x13f2('0x22'),_0x13f2('0x23'),_0x13f2('0x24'),_0x13f2('0x25')];function getRealtimeQueues(_0x33deb5,_0x114bab){var _0x3b66d4=_0x114bab===_0x13f2('0x26')?amiClient:routingClient;return _0x3b66d4['request'](_[_0x13f2('0x27')](_0x114bab)+_0x13f2('0x28'),_0x33deb5)[_0x13f2('0x29')](function(_0x2eb8d1){if(_0x2eb8d1[_0x13f2('0x2a')])throw new Error(util['format']('Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues',_0x114bab));return _0x2eb8d1[_0x13f2('0x2b')];})['catch'](function(_0x4a5fe8){throw _0x4a5fe8;});}exports['getRealtimeQueues']=getRealtimeQueues;function initializeQueues(_0x3b7867,_0x293167,_0x1e26d7,_0x47a490){var _0x7917ab=DEFAULT_QUEUE_ATTRIBUTES;if(_0x1e26d7===_0x13f2('0x26')){if(_0x47a490==='inbound'){_0x7917ab=_0x7917ab[_0x13f2('0x2c')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x47a490===_0x13f2('0x2d')){_0x7917ab=_0x7917ab[_0x13f2('0x2c')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x3b7867[_0x13f2('0x2e')](function(_0xd0b1d9){var _0x6ba8b2=_0xd0b1d9[_0x13f2('0x2f')]({'plain':!![]});_0x6ba8b2[_0x13f2('0x7')]=0x0;_0x6ba8b2['loggedInDb']=0x0;_0x6ba8b2[_0x13f2('0x6')]=0x0;_0x6ba8b2['available']=0x0;_0x6ba8b2[_0x13f2('0x30')]=0x0;if(_0x1e26d7==='voice'){_0x6ba8b2[_0x13f2('0x10')]=0x0;_0x6ba8b2[_0x13f2('0x8')]=0x0;if(_0x47a490===_0x13f2('0x2d')){_0x6ba8b2[_0x13f2('0x13')]=0x0;_0x6ba8b2['originated']=0x0;}}var _0x5ae9b6=_[_0x13f2('0x31')](_0x293167,['id',_0x6ba8b2['id']]);if(_0x5ae9b6){_[_0x13f2('0x32')](_0x6ba8b2,_[_0x13f2('0x33')](_0x5ae9b6,_0x7917ab));}return _0x6ba8b2;});}exports[_0x13f2('0x34')]=initializeQueues;