Built motion from commit (unavailable).|2.2.5
[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 _0x5179=['name','notificationSound','account','notificationShake','body','queue','msg','I\x20can\x27t\x20render\x20your\x20template','error','message','format','notification:%s','remove','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','BUSY','online','OFFLINE','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','redis','defaults','localhost','socket.io-emitter','emit','user:%s','split','\x20interaction'];(function(_0x562c96,_0x301853){var _0x3d3d9d=function(_0x4bdad2){while(--_0x4bdad2){_0x562c96['push'](_0x562c96['shift']());}};_0x3d3d9d(++_0x301853);}(_0x5179,0x1d2));var _0x9517=function(_0x11a962,_0x3cc338){_0x11a962=_0x11a962-0x0;var _0x55d423=_0x5179[_0x11a962];return _0x55d423;};'use strict';var _=require(_0x9517('0x0'));var util=require(_0x9517('0x1'));var utils=require(_0x9517('0x2'));var Mustache=require('mustache');var Redis=require(_0x9517('0x3'));var config=require(_0x9517('0x4'));var logger=require(_0x9517('0x5'))('routing');config[_0x9517('0x6')]=_[_0x9517('0x7')](config['redis'],{'host':_0x9517('0x8'),'port':0x18eb});var io=require(_0x9517('0x9'))(new Redis(config['redis']));function emit(_0x1572ae,_0x1f5da5,_0x4a5d2a){io['to'](_0x1572ae)[_0x9517('0xa')](_0x1f5da5,_0x4a5d2a);}function sendNotification(_0x38ea4c,_0x340018,_0x81f5d9,_0x34bcdc,_0x51e7ef,_0xb213aa){io['to'](util['format'](_0x9517('0xb'),_0x34bcdc['name']))['emit']('user:save',_0x34bcdc);var _0x53aa61=_0xb213aa||{};var _0x4443bd=_0x81f5d9[_0x9517('0xc')]('.');var _0x2109ba={'uniqueid':_0x340018,'channel':_0x4443bd[0x0],'id':_0x4443bd[0x1],'title':_0x4443bd[0x0]+_0x9517('0xd'),'interactionId':_0x4443bd[0x2],'queue':_0x51e7ef?_0x51e7ef[_0x9517('0xe')]:null,'sound':_0x53aa61['account'][_0x9517('0xf')],'shake':_0x53aa61[_0x9517('0x10')][_0x9517('0x11')]};try{if(!_0x53aa61[_0x9517('0x12')]){_0x53aa61[_0x9517('0x12')]={};}if(_0x51e7ef){_0x53aa61[_0x9517('0x12')]['queue']=_0x51e7ef;}else if(_0x53aa61[_0x9517('0x12')][_0x9517('0x13')]){delete _0x53aa61['body']['queue'];}_0x2109ba[_0x9517('0x14')]=utils['getMustacheRender'](_0x53aa61['account']['notificationTemplate'],_0x53aa61);}catch(_0x41e36b){_0x2109ba['msg']=_0x9517('0x15');logger[_0x9517('0x16')](util['format']('[%s][QUEUE]\x20%s',_0x340018,_0x41e36b[_0x9517('0x17')]));}io['to'](util[_0x9517('0x18')](_0x9517('0xb'),_0x34bcdc[_0x9517('0xe')]))[_0x9517('0xa')](util[_0x9517('0x18')](_0x9517('0x19'),_0x38ea4c?'save':_0x9517('0x1a')),_0x2109ba);}function writeLog(_0x4582cf,_0x224f80,_0x2a69c4){return logger['info'](util['format'](_0x9517('0x1b'),_0x4582cf,_0x224f80[_0x9517('0xe')],_0x2a69c4));}exports[_0x9517('0x1c')]=function(_0x361682,_0x29c64c,_0x4b880f,_0x1ea814){if(_0x29c64c['busy']){writeLog(_0x361682,_0x29c64c,_0x9517('0x1d'));return![];}if(!_0x29c64c[_0x9517('0x1e')]){writeLog(_0x361682,_0x29c64c,_0x9517('0x1f'));return![];}if(_0x29c64c[_0x4b880f+'Pause']){writeLog(_0x361682,_0x29c64c,_0x9517('0x20'));return![];}if(_0x1ea814&&_0x29c64c[_0x9517('0x21')](_0x4b880f+'Capacity')&&_0x29c64c[_0x9517('0x21')](_0x4b880f+'CurrentCapacity')){if(_0x29c64c[_0x4b880f+_0x9517('0x22')]>0x0&&_0x29c64c[_0x4b880f+_0x9517('0x23')]>=_0x29c64c[_0x4b880f+_0x9517('0x22')]){writeLog(_0x361682,_0x29c64c,_0x4b880f['toUpperCase']()+_0x9517('0x24'));return![];}}return!![];};exports[_0x9517('0x25')]=function(_0x92cf14,_0x4fbb07,_0x3ea510,_0x551482,_0x39c29e){return sendNotification(!![],_0x92cf14,_0x4fbb07,_0x3ea510,_0x551482,_0x39c29e);};exports[_0x9517('0x26')]=function(_0x1e60c8,_0x1ac44a,_0x20b725,_0xcaf9fa,_0x4d5d8e){return sendNotification(![],_0x1e60c8,_0x1ac44a,_0x20b725,_0xcaf9fa,_0x4d5d8e);};exports[_0x9517('0x27')]=writeLog;