Built motion from commit da617fac.|2.6.6
[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 _0x032e=['toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','../utils','ioredis','routing','redis','defaults','localhost','socket.io-emitter','format','user:%s','name','emit','user:save','split','\x20interaction','account','notificationSound','notificationShake','body','queue','msg','getMustacheRender','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','OFFLINE','Pause','PAUSE','CurrentCapacity','Capacity'];(function(_0x362add,_0x47dccf){var _0x44a7f2=function(_0x365072){while(--_0x365072){_0x362add['push'](_0x362add['shift']());}};_0x44a7f2(++_0x47dccf);}(_0x032e,0x124));var _0xe032=function(_0x2b5eae,_0x55010d){_0x2b5eae=_0x2b5eae-0x0;var _0x5f3ac9=_0x032e[_0x2b5eae];return _0x5f3ac9;};'use strict';var _=require(_0xe032('0x0'));var util=require('util');var utils=require(_0xe032('0x1'));var Redis=require(_0xe032('0x2'));var config=require('../../../../../config/environment');var logger=require('../../../../../config/logger')(_0xe032('0x3'));config[_0xe032('0x4')]=_[_0xe032('0x5')](config[_0xe032('0x4')],{'host':_0xe032('0x6'),'port':0x18eb});var io=require(_0xe032('0x7'))(new Redis(config[_0xe032('0x4')]));function sendNotification(_0x33ad0b,_0x37432f,_0x1576c8,_0x3289b0,_0xd84027,_0xaf3907){io['to'](util[_0xe032('0x8')](_0xe032('0x9'),_0x3289b0[_0xe032('0xa')]))[_0xe032('0xb')](_0xe032('0xc'),_0x3289b0);var _0x4aec53=_0xaf3907||{};var _0x1382e1=_0x1576c8[_0xe032('0xd')]('.');var _0x13c126={'uniqueid':_0x37432f,'channel':_0x1382e1[0x0],'id':_0x1382e1[0x1],'title':_0x1382e1[0x0]+_0xe032('0xe'),'interactionId':_0x1382e1[0x2],'queue':_0xd84027?_0xd84027[_0xe032('0xa')]:null,'sound':_0x4aec53[_0xe032('0xf')][_0xe032('0x10')],'shake':_0x4aec53['account'][_0xe032('0x11')]};try{if(!_0x4aec53[_0xe032('0x12')]){_0x4aec53[_0xe032('0x12')]={};}if(_0xd84027){_0x4aec53[_0xe032('0x12')]['queue']=_0xd84027;}else if(_0x4aec53[_0xe032('0x12')][_0xe032('0x13')]){delete _0x4aec53[_0xe032('0x12')][_0xe032('0x13')];}_0x13c126[_0xe032('0x14')]=utils[_0xe032('0x15')](_0x4aec53[_0xe032('0xf')]['notificationTemplate'],_0x4aec53);}catch(_0x231c35){_0x13c126[_0xe032('0x14')]=_0xe032('0x16');logger[_0xe032('0x17')](util[_0xe032('0x8')](_0xe032('0x18'),_0x37432f,_0x231c35['message']));}io['to'](util[_0xe032('0x8')](_0xe032('0x9'),_0x3289b0[_0xe032('0xa')]))[_0xe032('0xb')](util[_0xe032('0x8')]('notification:%s',_0x33ad0b?'save':'remove'),_0x13c126);}function writeLog(_0x15475c,_0x505d8c,_0x46dc27){return logger[_0xe032('0x19')](util[_0xe032('0x8')](_0xe032('0x1a'),_0x15475c,_0x505d8c[_0xe032('0xa')],_0x46dc27));}exports[_0xe032('0x1b')]=function(_0x136f5d,_0x5a7b53,_0x32f8b6,_0x866c81){if(_0x5a7b53[_0xe032('0x1c')]){writeLog(_0x136f5d,_0x5a7b53,_0xe032('0x1d'));return![];}if(!_0x5a7b53[_0xe032('0x1e')]){writeLog(_0x136f5d,_0x5a7b53,_0xe032('0x1f'));return![];}if(_0x5a7b53[_0x32f8b6+_0xe032('0x20')]){writeLog(_0x136f5d,_0x5a7b53,_0xe032('0x21'));return![];}if(_0x866c81&&_0x5a7b53['hasOwnProperty'](_0x32f8b6+'Capacity')&&_0x5a7b53['hasOwnProperty'](_0x32f8b6+_0xe032('0x22'))){if(_0x5a7b53[_0x32f8b6+_0xe032('0x23')]>0x0&&_0x5a7b53[_0x32f8b6+_0xe032('0x22')]>=_0x5a7b53[_0x32f8b6+_0xe032('0x23')]){writeLog(_0x136f5d,_0x5a7b53,_0x32f8b6[_0xe032('0x24')]()+_0xe032('0x25'));return![];}}return!![];};exports[_0xe032('0x26')]=function(_0x2b6ffa,_0x4dcbf1,_0x1ac20b,_0x5bb36a,_0x189ed4){return sendNotification(!![],_0x2b6ffa,_0x4dcbf1,_0x1ac20b,_0x5bb36a,_0x189ed4);};exports[_0xe032('0x27')]=function(_0x3106aa,_0x2a521b,_0x5cc95d,_0x5573e4,_0x3e2575){return sendNotification(![],_0x3106aa,_0x2a521b,_0x5cc95d,_0x5573e4,_0x3e2575);};exports[_0xe032('0x28')]=writeLog;