Built motion from commit 616d3211.|2.6.4
[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 _0xa630=['redis','localhost','socket.io-emitter','format','name','emit','user:save','split','\x20interaction','account','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','[%s][QUEUE]\x20%s','message','user:%s','notification:%s','save','remove','isAgentAvailable','BUSY','online','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','toUpperCase','hideNotification','writeLog','lodash','util','../../../../../config/environment','routing','defaults'];(function(_0x12566c,_0x19665f){var _0x8c8fc=function(_0x3d3df4){while(--_0x3d3df4){_0x12566c['push'](_0x12566c['shift']());}};_0x8c8fc(++_0x19665f);}(_0xa630,0xbe));var _0x0a63=function(_0x95ff8e,_0x217067){_0x95ff8e=_0x95ff8e-0x0;var _0x412269=_0xa630[_0x95ff8e];return _0x412269;};'use strict';var _=require(_0x0a63('0x0'));var util=require(_0x0a63('0x1'));var utils=require('../utils');var Redis=require('ioredis');var config=require(_0x0a63('0x2'));var logger=require('../../../../../config/logger')(_0x0a63('0x3'));config['redis']=_[_0x0a63('0x4')](config[_0x0a63('0x5')],{'host':_0x0a63('0x6'),'port':0x18eb});var io=require(_0x0a63('0x7'))(new Redis(config[_0x0a63('0x5')]));function sendNotification(_0x4b7474,_0x2760b0,_0x3d5f0b,_0xc2dcd7,_0x41d21d,_0x12a7df){io['to'](util[_0x0a63('0x8')]('user:%s',_0xc2dcd7[_0x0a63('0x9')]))[_0x0a63('0xa')](_0x0a63('0xb'),_0xc2dcd7);var _0x218142=_0x12a7df||{};var _0x327bb0=_0x3d5f0b[_0x0a63('0xc')]('.');var _0x207434={'uniqueid':_0x2760b0,'channel':_0x327bb0[0x0],'id':_0x327bb0[0x1],'title':_0x327bb0[0x0]+_0x0a63('0xd'),'interactionId':_0x327bb0[0x2],'queue':_0x41d21d?_0x41d21d[_0x0a63('0x9')]:null,'sound':_0x218142[_0x0a63('0xe')]['notificationSound'],'shake':_0x218142[_0x0a63('0xe')][_0x0a63('0xf')]};try{if(!_0x218142[_0x0a63('0x10')]){_0x218142[_0x0a63('0x10')]={};}if(_0x41d21d){_0x218142['body'][_0x0a63('0x11')]=_0x41d21d;}else if(_0x218142['body'][_0x0a63('0x11')]){delete _0x218142[_0x0a63('0x10')][_0x0a63('0x11')];}_0x207434[_0x0a63('0x12')]=utils[_0x0a63('0x13')](_0x218142[_0x0a63('0xe')][_0x0a63('0x14')],_0x218142);}catch(_0x1e3251){_0x207434['msg']=_0x0a63('0x15');logger['error'](util[_0x0a63('0x8')](_0x0a63('0x16'),_0x2760b0,_0x1e3251[_0x0a63('0x17')]));}io['to'](util[_0x0a63('0x8')](_0x0a63('0x18'),_0xc2dcd7[_0x0a63('0x9')]))[_0x0a63('0xa')](util[_0x0a63('0x8')](_0x0a63('0x19'),_0x4b7474?_0x0a63('0x1a'):_0x0a63('0x1b')),_0x207434);}function writeLog(_0x4ea56f,_0x550568,_0x7b2ccd){return logger['debug'](util[_0x0a63('0x8')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0x4ea56f,_0x550568[_0x0a63('0x9')],_0x7b2ccd));}exports[_0x0a63('0x1c')]=function(_0x145625,_0x46b968,_0x5da46b,_0x398a16){if(_0x46b968['busy']){writeLog(_0x145625,_0x46b968,_0x0a63('0x1d'));return![];}if(!_0x46b968[_0x0a63('0x1e')]){writeLog(_0x145625,_0x46b968,_0x0a63('0x1f'));return![];}if(_0x46b968[_0x5da46b+_0x0a63('0x20')]){writeLog(_0x145625,_0x46b968,_0x0a63('0x21'));return![];}if(_0x398a16&&_0x46b968[_0x0a63('0x22')](_0x5da46b+_0x0a63('0x23'))&&_0x46b968[_0x0a63('0x22')](_0x5da46b+'CurrentCapacity')){if(_0x46b968[_0x5da46b+'Capacity']>0x0&&_0x46b968[_0x5da46b+'CurrentCapacity']>=_0x46b968[_0x5da46b+'Capacity']){writeLog(_0x145625,_0x46b968,_0x5da46b[_0x0a63('0x24')]()+'\x20MAXCAPACITY');return![];}}return!![];};exports['showNotification']=function(_0x2133cf,_0x1d5448,_0x362d6a,_0x2e2526,_0x52e7ef){return sendNotification(!![],_0x2133cf,_0x1d5448,_0x362d6a,_0x2e2526,_0x52e7ef);};exports[_0x0a63('0x25')]=function(_0x498371,_0x25ab82,_0x5772f8,_0x34239b,_0xcf409){return sendNotification(![],_0x498371,_0x25ab82,_0x5772f8,_0x34239b,_0xcf409);};exports[_0x0a63('0x26')]=writeLog;