2b5890f59913ba56a70ef84713552fb64e010371
[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 _0x3070=['invalid','notInUse','ringing','unavailable','unknown','originated','message','statusMessage','startPredictive','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','voice','request','startCase','Queues','then','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','concat','outbound','map','loggedInDb','busy','pTalking','merge','pick','initializeQueues','jayson/promise','util','client','http','available','loggedIn','paused','waiting','inUse'];(function(_0x5e068e,_0x28ff2e){var _0x329514=function(_0x1c9815){while(--_0x1c9815){_0x5e068e['push'](_0x5e068e['shift']());}};_0x329514(++_0x28ff2e);}(_0x3070,0x10b));var _0x0307=function(_0x4139b8,_0x59a79a){_0x4139b8=_0x4139b8-0x0;var _0x5179b6=_0x3070[_0x4139b8];return _0x5179b6;};'use strict';var _=require('lodash');var jayson=require(_0x0307('0x0'));var util=require(_0x0307('0x1'));var amiClient=jayson[_0x0307('0x2')]['http']({'port':0x232a});var routingClient=jayson[_0x0307('0x2')][_0x0307('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x0307('0x4'),_0x0307('0x5'),_0x0307('0x6'),_0x0307('0x7')];var VOICE_QUEUE_ATTRIBUTES=['busy',_0x0307('0x8'),_0x0307('0x9'),'loggedInDb',_0x0307('0xa'),'onHold',_0x0307('0xb'),'ringInUse','talking',_0x0307('0xc'),_0x0307('0xd')];var OUTBOUND_QUEUE_ATTRIBUTES=['pTalking',_0x0307('0xe'),_0x0307('0xf'),_0x0307('0x10'),'dialActive','dialMethod','Trunk',_0x0307('0x11'),'startProgressive','erlangCalls','erlangCallToSecond',_0x0307('0x12'),_0x0307('0x13'),_0x0307('0x14'),_0x0307('0x15'),_0x0307('0x16'),_0x0307('0x17'),_0x0307('0x18'),_0x0307('0x19'),'predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit',_0x0307('0x1a'),_0x0307('0x1b')];function getRealtimeQueues(_0xf9edc1,_0x10ec3a){var _0x4bbdd5=_0x10ec3a===_0x0307('0x1c')?amiClient:routingClient;return _0x4bbdd5[_0x0307('0x1d')](_[_0x0307('0x1e')](_0x10ec3a)+_0x0307('0x1f'),_0xf9edc1)[_0x0307('0x20')](function(_0x3b48c3){if(_0x3b48c3['error'])throw new Error(util[_0x0307('0x21')](_0x0307('0x22'),_0x10ec3a));return _0x3b48c3[_0x0307('0x23')];})[_0x0307('0x24')](function(_0x4a7fbd){throw _0x4a7fbd;});}exports['getRealtimeQueues']=getRealtimeQueues;function initializeQueues(_0x2aad8b,_0x21016b,_0x10154e,_0xa411bb){var _0x315e83=DEFAULT_QUEUE_ATTRIBUTES;if(_0x10154e===_0x0307('0x1c')){if(_0xa411bb==='inbound'){_0x315e83=_0x315e83[_0x0307('0x25')](VOICE_QUEUE_ATTRIBUTES);}else if(_0xa411bb===_0x0307('0x26')){_0x315e83=_0x315e83[_0x0307('0x25')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x2aad8b[_0x0307('0x27')](function(_0x31f56f){var _0x24319d=_0x31f56f['get']({'plain':!![]});_0x24319d[_0x0307('0x6')]=0x0;_0x24319d[_0x0307('0x28')]=0x0;_0x24319d[_0x0307('0x5')]=0x0;_0x24319d[_0x0307('0x4')]=0x0;_0x24319d[_0x0307('0x7')]=0x0;if(_0x10154e===_0x0307('0x1c')){_0x24319d['talking']=0x0;_0x24319d[_0x0307('0x29')]=0x0;if(_0xa411bb==='outbound'){_0x24319d[_0x0307('0x2a')]=0x0;_0x24319d['originated']=0x0;}}var _0x1291fc=_['find'](_0x21016b,['id',_0x24319d['id']]);if(_0x1291fc){_[_0x0307('0x2b')](_0x24319d,_[_0x0307('0x2c')](_0x1291fc,_0x315e83));}return _0x24319d;});}exports[_0x0307('0x2d')]=initializeQueues;