Built motion from commit (unavailable).|2.5.25
[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 _0xea67=['redis','localhost','socket.io-emitter','emit','format','user:save','split','name','account','notificationSound','notificationShake','body','queue','msg','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','[%s][QUEUE]\x20%s','message','notification:%s','save','remove','info','isAgentAvailable','busy','online','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','../../../../../config/environment','../../../../../config/logger','routing','defaults'];(function(_0x3bd5fb,_0x1e5220){var _0x4849d4=function(_0x19b88d){while(--_0x19b88d){_0x3bd5fb['push'](_0x3bd5fb['shift']());}};_0x4849d4(++_0x1e5220);}(_0xea67,0x172));var _0x7ea6=function(_0x333fed,_0x3d2122){_0x333fed=_0x333fed-0x0;var _0x12cac2=_0xea67[_0x333fed];return _0x12cac2;};'use strict';var _=require(_0x7ea6('0x0'));var util=require(_0x7ea6('0x1'));var utils=require(_0x7ea6('0x2'));var Mustache=require(_0x7ea6('0x3'));var Redis=require('ioredis');var config=require(_0x7ea6('0x4'));var logger=require(_0x7ea6('0x5'))(_0x7ea6('0x6'));config['redis']=_[_0x7ea6('0x7')](config[_0x7ea6('0x8')],{'host':_0x7ea6('0x9'),'port':0x18eb});var io=require(_0x7ea6('0xa'))(new Redis(config[_0x7ea6('0x8')]));function emit(_0x1b5ce8,_0x2cc5cb,_0x14904f){io['to'](_0x1b5ce8)[_0x7ea6('0xb')](_0x2cc5cb,_0x14904f);}function sendNotification(_0x59f2c9,_0x208396,_0x51b4c7,_0x383f6e,_0x4c0fc4,_0x2a6cd4){io['to'](util[_0x7ea6('0xc')]('user:%s',_0x383f6e['name']))[_0x7ea6('0xb')](_0x7ea6('0xd'),_0x383f6e);var _0x477d64=_0x2a6cd4||{};var _0x4d453b=_0x51b4c7[_0x7ea6('0xe')]('.');var _0x4321f0={'uniqueid':_0x208396,'channel':_0x4d453b[0x0],'id':_0x4d453b[0x1],'title':_0x4d453b[0x0]+'\x20interaction','interactionId':_0x4d453b[0x2],'queue':_0x4c0fc4?_0x4c0fc4[_0x7ea6('0xf')]:null,'sound':_0x477d64[_0x7ea6('0x10')][_0x7ea6('0x11')],'shake':_0x477d64['account'][_0x7ea6('0x12')]};try{if(!_0x477d64[_0x7ea6('0x13')]){_0x477d64['body']={};}if(_0x4c0fc4){_0x477d64['body'][_0x7ea6('0x14')]=_0x4c0fc4;}else if(_0x477d64[_0x7ea6('0x13')][_0x7ea6('0x14')]){delete _0x477d64[_0x7ea6('0x13')][_0x7ea6('0x14')];}_0x4321f0[_0x7ea6('0x15')]=utils['getMustacheRender'](_0x477d64[_0x7ea6('0x10')][_0x7ea6('0x16')],_0x477d64);}catch(_0x48aa39){_0x4321f0[_0x7ea6('0x15')]=_0x7ea6('0x17');logger['error'](util[_0x7ea6('0xc')](_0x7ea6('0x18'),_0x208396,_0x48aa39[_0x7ea6('0x19')]));}io['to'](util[_0x7ea6('0xc')]('user:%s',_0x383f6e['name']))[_0x7ea6('0xb')](util[_0x7ea6('0xc')](_0x7ea6('0x1a'),_0x59f2c9?_0x7ea6('0x1b'):_0x7ea6('0x1c')),_0x4321f0);}function writeLog(_0xc41492,_0xfdde83,_0x6e1c73){return logger[_0x7ea6('0x1d')](util[_0x7ea6('0xc')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0xc41492,_0xfdde83[_0x7ea6('0xf')],_0x6e1c73));}exports[_0x7ea6('0x1e')]=function(_0x43ce58,_0x379ba6,_0x588bb6,_0x4b01fd){if(_0x379ba6[_0x7ea6('0x1f')]){writeLog(_0x43ce58,_0x379ba6,'BUSY');return![];}if(!_0x379ba6[_0x7ea6('0x20')]){writeLog(_0x43ce58,_0x379ba6,_0x7ea6('0x21'));return![];}if(_0x379ba6[_0x588bb6+_0x7ea6('0x22')]){writeLog(_0x43ce58,_0x379ba6,'PAUSE');return![];}if(_0x4b01fd&&_0x379ba6[_0x7ea6('0x23')](_0x588bb6+_0x7ea6('0x24'))&&_0x379ba6[_0x7ea6('0x23')](_0x588bb6+_0x7ea6('0x25'))){if(_0x379ba6[_0x588bb6+_0x7ea6('0x24')]>0x0&&_0x379ba6[_0x588bb6+'CurrentCapacity']>=_0x379ba6[_0x588bb6+'Capacity']){writeLog(_0x43ce58,_0x379ba6,_0x588bb6['toUpperCase']()+_0x7ea6('0x26'));return![];}}return!![];};exports[_0x7ea6('0x27')]=function(_0x3a5c28,_0x1aabfa,_0x3dba09,_0x5267eb,_0x471413){return sendNotification(!![],_0x3a5c28,_0x1aabfa,_0x3dba09,_0x5267eb,_0x471413);};exports[_0x7ea6('0x28')]=function(_0x35fa3c,_0x1e9ec2,_0x161fe9,_0x362967,_0x2d64e9){return sendNotification(![],_0x35fa3c,_0x1e9ec2,_0x161fe9,_0x362967,_0x2d64e9);};exports[_0x7ea6('0x29')]=writeLog;