Built motion from commit (unavailable).|2.0.71
[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 _0x9294=['getMustacheRender','I\x20can\x27t\x20render\x20your\x20template','error','format','[%s][QUEUE]\x20%s','message','notification:%s','save','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','Pause','hasOwnProperty','Capacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','util','../utils','../../../../../config/logger','routing','socket.io-emitter','localhost','emit','user:%s','\x20interaction','name','account','notificationSound','notificationShake','body','queue','msg'];(function(_0xb68772,_0x5253ac){var _0x4189bb=function(_0x1b0cf3){while(--_0x1b0cf3){_0xb68772['push'](_0xb68772['shift']());}};_0x4189bb(++_0x5253ac);}(_0x9294,0x187));var _0x4929=function(_0x493b70,_0x168e73){_0x493b70=_0x493b70-0x0;var _0x4c2355=_0x9294[_0x493b70];return _0x4c2355;};'use strict';var util=require(_0x4929('0x0'));var utils=require(_0x4929('0x1'));var Mustache=require('mustache');var logger=require(_0x4929('0x2'))(_0x4929('0x3'));var io=require(_0x4929('0x4'))({'host':_0x4929('0x5'),'port':0x18eb});function emit(_0x371d74,_0x260be2,_0x3cddf3){io['to'](_0x371d74)[_0x4929('0x6')](_0x260be2,_0x3cddf3);}function sendNotification(_0xc452e6,_0x27d698,_0x3d7d76,_0x5fd1b8,_0x1b9246,_0x10a332){io['to'](util['format'](_0x4929('0x7'),_0x5fd1b8['name']))[_0x4929('0x6')]('user:save',_0x5fd1b8);var _0x1df960=_0x10a332||{};var _0x47eb7d=_0x3d7d76['split']('.');var _0x26781f={'uniqueid':_0x27d698,'channel':_0x47eb7d[0x0],'id':_0x47eb7d[0x1],'title':_0x47eb7d[0x0]+_0x4929('0x8'),'interactionId':_0x47eb7d[0x2],'queue':_0x1b9246?_0x1b9246[_0x4929('0x9')]:null,'sound':_0x1df960[_0x4929('0xa')][_0x4929('0xb')],'shake':_0x1df960['account'][_0x4929('0xc')]};try{if(!_0x1df960[_0x4929('0xd')]){_0x1df960[_0x4929('0xd')]={};}if(_0x1b9246){_0x1df960['body']['queue']=_0x1b9246;}else if(_0x1df960[_0x4929('0xd')]['queue']){delete _0x1df960[_0x4929('0xd')][_0x4929('0xe')];}_0x26781f[_0x4929('0xf')]=utils[_0x4929('0x10')](_0x1df960[_0x4929('0xa')]['notificationTemplate'],_0x1df960);}catch(_0x27c3c8){_0x26781f[_0x4929('0xf')]=_0x4929('0x11');logger[_0x4929('0x12')](util[_0x4929('0x13')](_0x4929('0x14'),_0x27d698,_0x27c3c8[_0x4929('0x15')]));}io['to'](util[_0x4929('0x13')](_0x4929('0x7'),_0x5fd1b8[_0x4929('0x9')]))[_0x4929('0x6')](util[_0x4929('0x13')](_0x4929('0x16'),_0xc452e6?_0x4929('0x17'):'remove'),_0x26781f);}function writeLog(_0x215037,_0x35bd71,_0x2fbdd6){return logger[_0x4929('0x18')](util[_0x4929('0x13')](_0x4929('0x19'),_0x215037,_0x35bd71[_0x4929('0x9')],_0x2fbdd6));}exports[_0x4929('0x1a')]=function(_0x1c85e3,_0x3edb71,_0x5268e9,_0x417f02){if(_0x3edb71[_0x4929('0x1b')]){writeLog(_0x1c85e3,_0x3edb71,_0x4929('0x1c'));return![];}if(!_0x3edb71['online']){writeLog(_0x1c85e3,_0x3edb71,'OFFLINE');return![];}if(_0x3edb71[_0x5268e9+_0x4929('0x1d')]){writeLog(_0x1c85e3,_0x3edb71,'PAUSE');return![];}if(_0x417f02&&_0x3edb71[_0x4929('0x1e')](_0x5268e9+_0x4929('0x1f'))&&_0x3edb71[_0x4929('0x1e')](_0x5268e9+'CurrentCapacity')){if(_0x3edb71[_0x5268e9+_0x4929('0x1f')]>0x0&&_0x3edb71[_0x5268e9+'CurrentCapacity']>=_0x3edb71[_0x5268e9+'Capacity']){writeLog(_0x1c85e3,_0x3edb71,_0x5268e9[_0x4929('0x20')]()+_0x4929('0x21'));return![];}}return!![];};exports[_0x4929('0x22')]=function(_0xaa9638,_0x36ed2a,_0x148f97,_0x43e481,_0x14c555){return sendNotification(!![],_0xaa9638,_0x36ed2a,_0x148f97,_0x43e481,_0x14c555);};exports[_0x4929('0x23')]=function(_0x451ee0,_0x28b6cf,_0x56c0d0,_0xfe67db,_0x19c5e6){return sendNotification(![],_0x451ee0,_0x28b6cf,_0x56c0d0,_0xfe67db,_0x19c5e6);};exports[_0x4929('0x24')]=writeLog;