9a29f64ed7b179f913032ba65ea03ecf14dad4d7
[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 _0xeda8=['OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','\x20MAXCAPACITY','showNotification','writeLog','lodash','util','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults','localhost','socket.io-emitter','emit','format','user:%s','name','user:save','split','\x20interaction','account','notificationSound','body','queue','msg','I\x20can\x27t\x20render\x20your\x20template','error','message','notification:%s','save','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY'];(function(_0x15a2cb,_0x571a10){var _0x26d3f6=function(_0x2e313f){while(--_0x2e313f){_0x15a2cb['push'](_0x15a2cb['shift']());}};_0x26d3f6(++_0x571a10);}(_0xeda8,0x104));var _0x8eda=function(_0x176dfc,_0x3191a4){_0x176dfc=_0x176dfc-0x0;var _0x351cf6=_0xeda8[_0x176dfc];return _0x351cf6;};'use strict';var _=require(_0x8eda('0x0'));var util=require(_0x8eda('0x1'));var utils=require('../utils');var Mustache=require(_0x8eda('0x2'));var Redis=require(_0x8eda('0x3'));var config=require(_0x8eda('0x4'));var logger=require(_0x8eda('0x5'))(_0x8eda('0x6'));config[_0x8eda('0x7')]=_[_0x8eda('0x8')](config[_0x8eda('0x7')],{'host':_0x8eda('0x9'),'port':0x18eb});var io=require(_0x8eda('0xa'))(new Redis(config[_0x8eda('0x7')]));function emit(_0x32abe8,_0x4e2ebb,_0x28b721){io['to'](_0x32abe8)[_0x8eda('0xb')](_0x4e2ebb,_0x28b721);}function sendNotification(_0x5aa93d,_0x6b544f,_0x4be9df,_0x4f7893,_0x488849,_0x4fbf0a){io['to'](util[_0x8eda('0xc')](_0x8eda('0xd'),_0x4f7893[_0x8eda('0xe')]))['emit'](_0x8eda('0xf'),_0x4f7893);var _0x5a80ca=_0x4fbf0a||{};var _0x3f34c=_0x4be9df[_0x8eda('0x10')]('.');var _0x2fdec0={'uniqueid':_0x6b544f,'channel':_0x3f34c[0x0],'id':_0x3f34c[0x1],'title':_0x3f34c[0x0]+_0x8eda('0x11'),'interactionId':_0x3f34c[0x2],'queue':_0x488849?_0x488849[_0x8eda('0xe')]:null,'sound':_0x5a80ca[_0x8eda('0x12')][_0x8eda('0x13')],'shake':_0x5a80ca[_0x8eda('0x12')]['notificationShake']};try{if(!_0x5a80ca['body']){_0x5a80ca[_0x8eda('0x14')]={};}if(_0x488849){_0x5a80ca[_0x8eda('0x14')]['queue']=_0x488849;}else if(_0x5a80ca[_0x8eda('0x14')][_0x8eda('0x15')]){delete _0x5a80ca[_0x8eda('0x14')]['queue'];}_0x2fdec0[_0x8eda('0x16')]=utils['getMustacheRender'](_0x5a80ca[_0x8eda('0x12')]['notificationTemplate'],_0x5a80ca);}catch(_0x24aed4){_0x2fdec0['msg']=_0x8eda('0x17');logger[_0x8eda('0x18')](util['format']('[%s][QUEUE]\x20%s',_0x6b544f,_0x24aed4[_0x8eda('0x19')]));}io['to'](util[_0x8eda('0xc')](_0x8eda('0xd'),_0x4f7893[_0x8eda('0xe')]))[_0x8eda('0xb')](util[_0x8eda('0xc')](_0x8eda('0x1a'),_0x5aa93d?_0x8eda('0x1b'):_0x8eda('0x1c')),_0x2fdec0);}function writeLog(_0x232786,_0x279ade,_0x57f336){return logger[_0x8eda('0x1d')](util['format'](_0x8eda('0x1e'),_0x232786,_0x279ade['name'],_0x57f336));}exports[_0x8eda('0x1f')]=function(_0x2dab25,_0x4f3e0a,_0x58e54b,_0x56dba4){if(_0x4f3e0a[_0x8eda('0x20')]){writeLog(_0x2dab25,_0x4f3e0a,_0x8eda('0x21'));return![];}if(!_0x4f3e0a['online']){writeLog(_0x2dab25,_0x4f3e0a,_0x8eda('0x22'));return![];}if(_0x4f3e0a[_0x58e54b+_0x8eda('0x23')]){writeLog(_0x2dab25,_0x4f3e0a,'PAUSE');return![];}if(_0x56dba4&&_0x4f3e0a[_0x8eda('0x24')](_0x58e54b+_0x8eda('0x25'))&&_0x4f3e0a[_0x8eda('0x24')](_0x58e54b+_0x8eda('0x26'))){if(_0x4f3e0a[_0x58e54b+_0x8eda('0x25')]>0x0&&_0x4f3e0a[_0x58e54b+'CurrentCapacity']>=_0x4f3e0a[_0x58e54b+_0x8eda('0x25')]){writeLog(_0x2dab25,_0x4f3e0a,_0x58e54b['toUpperCase']()+_0x8eda('0x27'));return![];}}return!![];};exports[_0x8eda('0x28')]=function(_0x8337b4,_0x567f69,_0x23e892,_0x244400,_0x1dd12){return sendNotification(!![],_0x8337b4,_0x567f69,_0x23e892,_0x244400,_0x1dd12);};exports['hideNotification']=function(_0x1616ea,_0x11a999,_0x5dd315,_0x27d2ce,_0x29e6f4){return sendNotification(![],_0x1616ea,_0x11a999,_0x5dd315,_0x27d2ce,_0x29e6f4);};exports[_0x8eda('0x29')]=writeLog;