Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / services / routing / server / applications / strategy / util.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 _0x8ec8=['PAUSE','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','hideNotification','writeLog','lodash','mustache','ioredis','../../../../../config/logger','routing','redis','defaults','localhost','socket.io-emitter','emit','format','split','name','account','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','user:%s','save','isAgentAvailable','BUSY','online','OFFLINE'];(function(_0x8c7598,_0x1c6ebb){var _0x4d8ed1=function(_0x583255){while(--_0x583255){_0x8c7598['push'](_0x8c7598['shift']());}};_0x4d8ed1(++_0x1c6ebb);}(_0x8ec8,0x154));var _0x88ec=function(_0x53ccf2,_0x13cb67){_0x53ccf2=_0x53ccf2-0x0;var _0x5a2964=_0x8ec8[_0x53ccf2];return _0x5a2964;};'use strict';var _=require(_0x88ec('0x0'));var util=require('util');var utils=require('../utils');var Mustache=require(_0x88ec('0x1'));var Redis=require(_0x88ec('0x2'));var config=require('../../../../../config/environment');var logger=require(_0x88ec('0x3'))(_0x88ec('0x4'));config[_0x88ec('0x5')]=_[_0x88ec('0x6')](config[_0x88ec('0x5')],{'host':_0x88ec('0x7'),'port':0x18eb});var io=require(_0x88ec('0x8'))(new Redis(config[_0x88ec('0x5')]));function emit(_0x523ff8,_0x4327d7,_0x4a151b){io['to'](_0x523ff8)[_0x88ec('0x9')](_0x4327d7,_0x4a151b);}function sendNotification(_0x26118a,_0x1f96b2,_0x472290,_0x2a73bd,_0x726767,_0x3e2c55){io['to'](util[_0x88ec('0xa')]('user:%s',_0x2a73bd['name']))[_0x88ec('0x9')]('user:save',_0x2a73bd);var _0x24727c=_0x3e2c55||{};var _0x5367ee=_0x472290[_0x88ec('0xb')]('.');var _0xcc84f4={'uniqueid':_0x1f96b2,'channel':_0x5367ee[0x0],'id':_0x5367ee[0x1],'title':_0x5367ee[0x0]+'\x20interaction','interactionId':_0x5367ee[0x2],'queue':_0x726767?_0x726767[_0x88ec('0xc')]:null,'sound':_0x24727c[_0x88ec('0xd')]['notificationSound'],'shake':_0x24727c[_0x88ec('0xd')][_0x88ec('0xe')]};try{if(!_0x24727c['body']){_0x24727c[_0x88ec('0xf')]={};}if(_0x726767){_0x24727c[_0x88ec('0xf')][_0x88ec('0x10')]=_0x726767;}else if(_0x24727c[_0x88ec('0xf')][_0x88ec('0x10')]){delete _0x24727c[_0x88ec('0xf')][_0x88ec('0x10')];}_0xcc84f4[_0x88ec('0x11')]=utils[_0x88ec('0x12')](_0x24727c[_0x88ec('0xd')][_0x88ec('0x13')],_0x24727c);}catch(_0x1d5c7b){_0xcc84f4[_0x88ec('0x11')]=_0x88ec('0x14');logger[_0x88ec('0x15')](util[_0x88ec('0xa')](_0x88ec('0x16'),_0x1f96b2,_0x1d5c7b[_0x88ec('0x17')]));}io['to'](util[_0x88ec('0xa')](_0x88ec('0x18'),_0x2a73bd[_0x88ec('0xc')]))[_0x88ec('0x9')](util[_0x88ec('0xa')]('notification:%s',_0x26118a?_0x88ec('0x19'):'remove'),_0xcc84f4);}function writeLog(_0xa42b39,_0x15aa23,_0x47101c){return logger['info'](util[_0x88ec('0xa')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0xa42b39,_0x15aa23[_0x88ec('0xc')],_0x47101c));}exports[_0x88ec('0x1a')]=function(_0x22b04f,_0x43ecd0,_0x25104a,_0x51f3db){if(_0x43ecd0['busy']){writeLog(_0x22b04f,_0x43ecd0,_0x88ec('0x1b'));return![];}if(!_0x43ecd0[_0x88ec('0x1c')]){writeLog(_0x22b04f,_0x43ecd0,_0x88ec('0x1d'));return![];}if(_0x43ecd0[_0x25104a+'Pause']){writeLog(_0x22b04f,_0x43ecd0,_0x88ec('0x1e'));return![];}if(_0x51f3db&&_0x43ecd0['hasOwnProperty'](_0x25104a+_0x88ec('0x1f'))&&_0x43ecd0['hasOwnProperty'](_0x25104a+'CurrentCapacity')){if(_0x43ecd0[_0x25104a+_0x88ec('0x1f')]>0x0&&_0x43ecd0[_0x25104a+_0x88ec('0x20')]>=_0x43ecd0[_0x25104a+'Capacity']){writeLog(_0x22b04f,_0x43ecd0,_0x25104a[_0x88ec('0x21')]()+_0x88ec('0x22'));return![];}}return!![];};exports['showNotification']=function(_0x279869,_0x532e53,_0xb54e73,_0x1e6f61,_0x3e38af){return sendNotification(!![],_0x279869,_0x532e53,_0xb54e73,_0x1e6f61,_0x3e38af);};exports[_0x88ec('0x23')]=function(_0x4eef16,_0x1dbe41,_0x21a5a2,_0x302f40,_0x36bad){return sendNotification(![],_0x4eef16,_0x1dbe41,_0x21a5a2,_0x302f40,_0x36bad);};exports[_0x88ec('0x24')]=writeLog;