d7384dea12cf77bf836d7ef3ffafe23cd4544cac
[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 _0xa39f=['format','user:%s','name','split','\x20interaction','account','notificationSound','body','queue','notificationTemplate','msg','error','[%s][QUEUE]\x20%s','message','notification:%s','save','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults','localhost','emit'];(function(_0x1ddd0,_0x15f9f4){var _0x4d86d0=function(_0x3173d7){while(--_0x3173d7){_0x1ddd0['push'](_0x1ddd0['shift']());}};_0x4d86d0(++_0x15f9f4);}(_0xa39f,0x1e4));var _0xfa39=function(_0x37d1dd,_0x328b44){_0x37d1dd=_0x37d1dd-0x0;var _0x49539d=_0xa39f[_0x37d1dd];return _0x49539d;};'use strict';var _=require(_0xfa39('0x0'));var util=require(_0xfa39('0x1'));var utils=require(_0xfa39('0x2'));var Mustache=require('mustache');var Redis=require(_0xfa39('0x3'));var config=require(_0xfa39('0x4'));var logger=require(_0xfa39('0x5'))(_0xfa39('0x6'));config[_0xfa39('0x7')]=_[_0xfa39('0x8')](config[_0xfa39('0x7')],{'host':_0xfa39('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function emit(_0x3d47cc,_0xffa7ee,_0x4044bc){io['to'](_0x3d47cc)[_0xfa39('0xa')](_0xffa7ee,_0x4044bc);}function sendNotification(_0x9b132d,_0x58bd78,_0x46e10b,_0x1c2ed4,_0x1a41a4,_0xc9e0b5){io['to'](util[_0xfa39('0xb')](_0xfa39('0xc'),_0x1c2ed4[_0xfa39('0xd')]))[_0xfa39('0xa')]('user:save',_0x1c2ed4);var _0x853c32=_0xc9e0b5||{};var _0x8cd9e4=_0x46e10b[_0xfa39('0xe')]('.');var _0x37a7e4={'uniqueid':_0x58bd78,'channel':_0x8cd9e4[0x0],'id':_0x8cd9e4[0x1],'title':_0x8cd9e4[0x0]+_0xfa39('0xf'),'interactionId':_0x8cd9e4[0x2],'queue':_0x1a41a4?_0x1a41a4[_0xfa39('0xd')]:null,'sound':_0x853c32[_0xfa39('0x10')][_0xfa39('0x11')],'shake':_0x853c32[_0xfa39('0x10')]['notificationShake']};try{if(!_0x853c32['body']){_0x853c32[_0xfa39('0x12')]={};}if(_0x1a41a4){_0x853c32[_0xfa39('0x12')][_0xfa39('0x13')]=_0x1a41a4;}else if(_0x853c32['body']['queue']){delete _0x853c32[_0xfa39('0x12')][_0xfa39('0x13')];}_0x37a7e4['msg']=utils['getMustacheRender'](_0x853c32['account'][_0xfa39('0x14')],_0x853c32);}catch(_0x23b295){_0x37a7e4[_0xfa39('0x15')]='I\x20can\x27t\x20render\x20your\x20template';logger[_0xfa39('0x16')](util[_0xfa39('0xb')](_0xfa39('0x17'),_0x58bd78,_0x23b295[_0xfa39('0x18')]));}io['to'](util[_0xfa39('0xb')](_0xfa39('0xc'),_0x1c2ed4[_0xfa39('0xd')]))[_0xfa39('0xa')](util['format'](_0xfa39('0x19'),_0x9b132d?_0xfa39('0x1a'):_0xfa39('0x1b')),_0x37a7e4);}function writeLog(_0x461986,_0x20f16f,_0x55db8d){return logger[_0xfa39('0x1c')](util[_0xfa39('0xb')](_0xfa39('0x1d'),_0x461986,_0x20f16f[_0xfa39('0xd')],_0x55db8d));}exports[_0xfa39('0x1e')]=function(_0xc186e1,_0xce689d,_0x3d5dd2,_0x4e0cc5){if(_0xce689d[_0xfa39('0x1f')]){writeLog(_0xc186e1,_0xce689d,_0xfa39('0x20'));return![];}if(!_0xce689d[_0xfa39('0x21')]){writeLog(_0xc186e1,_0xce689d,_0xfa39('0x22'));return![];}if(_0xce689d[_0x3d5dd2+_0xfa39('0x23')]){writeLog(_0xc186e1,_0xce689d,_0xfa39('0x24'));return![];}if(_0x4e0cc5&&_0xce689d[_0xfa39('0x25')](_0x3d5dd2+_0xfa39('0x26'))&&_0xce689d[_0xfa39('0x25')](_0x3d5dd2+_0xfa39('0x27'))){if(_0xce689d[_0x3d5dd2+_0xfa39('0x26')]>0x0&&_0xce689d[_0x3d5dd2+'CurrentCapacity']>=_0xce689d[_0x3d5dd2+_0xfa39('0x26')]){writeLog(_0xc186e1,_0xce689d,_0x3d5dd2[_0xfa39('0x28')]()+_0xfa39('0x29'));return![];}}return!![];};exports[_0xfa39('0x2a')]=function(_0x44a4e3,_0x1ed28b,_0x255069,_0x15e3bb,_0x358fe3){return sendNotification(!![],_0x44a4e3,_0x1ed28b,_0x255069,_0x15e3bb,_0x358fe3);};exports[_0xfa39('0x2b')]=function(_0x3ff1bf,_0x46d660,_0x44981e,_0x58a669,_0x29e68b){return sendNotification(![],_0x3ff1bf,_0x46d660,_0x44981e,_0x58a669,_0x29e68b);};exports[_0xfa39('0x2c')]=writeLog;