f34c1164363004feca2dac5b7dbb99accc763c1f
[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 _0x8ef6=['socket.io-emitter','format','user:%s','name','emit','user:save','split','\x20interaction','notificationSound','account','notificationShake','body','queue','msg','getMustacheRender','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','notification:%s','save','remove','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','online','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','routing','defaults','redis','localhost'];(function(_0x31ad24,_0x17872b){var _0x23cb89=function(_0x5c6cc3){while(--_0x5c6cc3){_0x31ad24['push'](_0x31ad24['shift']());}};_0x23cb89(++_0x17872b);}(_0x8ef6,0xf2));var _0x68ef=function(_0x1a7092,_0x17dd1c){_0x1a7092=_0x1a7092-0x0;var _0x96edde=_0x8ef6[_0x1a7092];return _0x96edde;};'use strict';var _=require(_0x68ef('0x0'));var util=require(_0x68ef('0x1'));var utils=require(_0x68ef('0x2'));var Redis=require(_0x68ef('0x3'));var config=require(_0x68ef('0x4'));var logger=require(_0x68ef('0x5'))(_0x68ef('0x6'));config['redis']=_[_0x68ef('0x7')](config[_0x68ef('0x8')],{'host':_0x68ef('0x9'),'port':0x18eb});var io=require(_0x68ef('0xa'))(new Redis(config['redis']));function sendNotification(_0x4f77f3,_0x3c2ff3,_0x4740e8,_0x2de776,_0x4eb5eb,_0x228967){io['to'](util[_0x68ef('0xb')](_0x68ef('0xc'),_0x2de776[_0x68ef('0xd')]))[_0x68ef('0xe')](_0x68ef('0xf'),_0x2de776);var _0x304a60=_0x228967||{};var _0x23da00=_0x4740e8[_0x68ef('0x10')]('.');var _0x255c85={'uniqueid':_0x3c2ff3,'channel':_0x23da00[0x0],'id':_0x23da00[0x1],'title':_0x23da00[0x0]+_0x68ef('0x11'),'interactionId':_0x23da00[0x2],'queue':_0x4eb5eb?_0x4eb5eb[_0x68ef('0xd')]:null,'sound':_0x304a60['account'][_0x68ef('0x12')],'shake':_0x304a60[_0x68ef('0x13')][_0x68ef('0x14')]};try{if(!_0x304a60[_0x68ef('0x15')]){_0x304a60[_0x68ef('0x15')]={};}if(_0x4eb5eb){_0x304a60[_0x68ef('0x15')]['queue']=_0x4eb5eb;}else if(_0x304a60[_0x68ef('0x15')][_0x68ef('0x16')]){delete _0x304a60[_0x68ef('0x15')]['queue'];}_0x255c85[_0x68ef('0x17')]=utils[_0x68ef('0x18')](_0x304a60[_0x68ef('0x13')]['notificationTemplate'],_0x304a60);}catch(_0x35493d){_0x255c85[_0x68ef('0x17')]=_0x68ef('0x19');logger[_0x68ef('0x1a')](util['format'](_0x68ef('0x1b'),_0x3c2ff3,_0x35493d['message']));}io['to'](util['format'](_0x68ef('0xc'),_0x2de776[_0x68ef('0xd')]))['emit'](util['format'](_0x68ef('0x1c'),_0x4f77f3?_0x68ef('0x1d'):_0x68ef('0x1e')),_0x255c85);}function writeLog(_0x4fad1c,_0x1dc49c,_0x36a4cb){return logger[_0x68ef('0x1f')](util['format'](_0x68ef('0x20'),_0x4fad1c,_0x1dc49c[_0x68ef('0xd')],_0x36a4cb));}exports['isAgentAvailable']=function(_0x399da4,_0xf4760f,_0x19aa3d,_0x5ddec7){if(_0xf4760f['busy']){writeLog(_0x399da4,_0xf4760f,'BUSY');return![];}if(!_0xf4760f[_0x68ef('0x21')]){writeLog(_0x399da4,_0xf4760f,_0x68ef('0x22'));return![];}if(_0xf4760f[_0x19aa3d+_0x68ef('0x23')]){writeLog(_0x399da4,_0xf4760f,_0x68ef('0x24'));return![];}if(_0x5ddec7&&_0xf4760f[_0x68ef('0x25')](_0x19aa3d+_0x68ef('0x26'))&&_0xf4760f[_0x68ef('0x25')](_0x19aa3d+_0x68ef('0x27'))){if(_0xf4760f[_0x19aa3d+_0x68ef('0x26')]>0x0&&_0xf4760f[_0x19aa3d+_0x68ef('0x27')]>=_0xf4760f[_0x19aa3d+'Capacity']){writeLog(_0x399da4,_0xf4760f,_0x19aa3d[_0x68ef('0x28')]()+'\x20MAXCAPACITY');return![];}}return!![];};exports['showNotification']=function(_0x55d8b0,_0x1a7ce1,_0x268f32,_0x123041,_0x29518e){return sendNotification(!![],_0x55d8b0,_0x1a7ce1,_0x268f32,_0x123041,_0x29518e);};exports['hideNotification']=function(_0x4a0550,_0x1cbe4f,_0x28907a,_0x7bf96,_0x263b30){return sendNotification(![],_0x4a0550,_0x1cbe4f,_0x28907a,_0x7bf96,_0x263b30);};exports[_0x68ef('0x29')]=writeLog;