Built motion from commit 7ab0e143.|2.5.49
[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 _0x2da6=['toUpperCase','\x20MAXCAPACITY','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','localhost','socket.io-emitter','emit','user:%s','name','user:save','split','\x20interaction','account','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','error','[%s][QUEUE]\x20%s','message','format','notification:%s','save','remove','info','isAgentAvailable','busy','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity'];(function(_0x24a3ff,_0x29aaf8){var _0x46c08e=function(_0x5cc1a1){while(--_0x5cc1a1){_0x24a3ff['push'](_0x24a3ff['shift']());}};_0x46c08e(++_0x29aaf8);}(_0x2da6,0x1dd));var _0x62da=function(_0x599773,_0x4f17db){_0x599773=_0x599773-0x0;var _0x56e932=_0x2da6[_0x599773];return _0x56e932;};'use strict';var _=require(_0x62da('0x0'));var util=require(_0x62da('0x1'));var utils=require(_0x62da('0x2'));var Mustache=require(_0x62da('0x3'));var Redis=require(_0x62da('0x4'));var config=require(_0x62da('0x5'));var logger=require(_0x62da('0x6'))(_0x62da('0x7'));config['redis']=_['defaults'](config[_0x62da('0x8')],{'host':_0x62da('0x9'),'port':0x18eb});var io=require(_0x62da('0xa'))(new Redis(config[_0x62da('0x8')]));function emit(_0x100e73,_0x9d9139,_0x310c15){io['to'](_0x100e73)[_0x62da('0xb')](_0x9d9139,_0x310c15);}function sendNotification(_0xbfd2b0,_0x4cfc5d,_0x19b866,_0x2a3937,_0x2a3d7c,_0x1b68f8){io['to'](util['format'](_0x62da('0xc'),_0x2a3937[_0x62da('0xd')]))[_0x62da('0xb')](_0x62da('0xe'),_0x2a3937);var _0x23be32=_0x1b68f8||{};var _0x5c990c=_0x19b866[_0x62da('0xf')]('.');var _0x199b89={'uniqueid':_0x4cfc5d,'channel':_0x5c990c[0x0],'id':_0x5c990c[0x1],'title':_0x5c990c[0x0]+_0x62da('0x10'),'interactionId':_0x5c990c[0x2],'queue':_0x2a3d7c?_0x2a3d7c[_0x62da('0xd')]:null,'sound':_0x23be32[_0x62da('0x11')]['notificationSound'],'shake':_0x23be32['account'][_0x62da('0x12')]};try{if(!_0x23be32[_0x62da('0x13')]){_0x23be32[_0x62da('0x13')]={};}if(_0x2a3d7c){_0x23be32[_0x62da('0x13')][_0x62da('0x14')]=_0x2a3d7c;}else if(_0x23be32[_0x62da('0x13')][_0x62da('0x14')]){delete _0x23be32[_0x62da('0x13')][_0x62da('0x14')];}_0x199b89[_0x62da('0x15')]=utils[_0x62da('0x16')](_0x23be32[_0x62da('0x11')][_0x62da('0x17')],_0x23be32);}catch(_0x1aa4f3){_0x199b89['msg']='I\x20can\x27t\x20render\x20your\x20template';logger[_0x62da('0x18')](util['format'](_0x62da('0x19'),_0x4cfc5d,_0x1aa4f3[_0x62da('0x1a')]));}io['to'](util[_0x62da('0x1b')]('user:%s',_0x2a3937[_0x62da('0xd')]))['emit'](util[_0x62da('0x1b')](_0x62da('0x1c'),_0xbfd2b0?_0x62da('0x1d'):_0x62da('0x1e')),_0x199b89);}function writeLog(_0x3d015f,_0x267cef,_0x183033){return logger[_0x62da('0x1f')](util[_0x62da('0x1b')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0x3d015f,_0x267cef[_0x62da('0xd')],_0x183033));}exports[_0x62da('0x20')]=function(_0x2fd925,_0x1f6f96,_0x35f687,_0x54b936){if(_0x1f6f96[_0x62da('0x21')]){writeLog(_0x2fd925,_0x1f6f96,'BUSY');return![];}if(!_0x1f6f96['online']){writeLog(_0x2fd925,_0x1f6f96,'OFFLINE');return![];}if(_0x1f6f96[_0x35f687+_0x62da('0x22')]){writeLog(_0x2fd925,_0x1f6f96,_0x62da('0x23'));return![];}if(_0x54b936&&_0x1f6f96[_0x62da('0x24')](_0x35f687+_0x62da('0x25'))&&_0x1f6f96['hasOwnProperty'](_0x35f687+_0x62da('0x26'))){if(_0x1f6f96[_0x35f687+_0x62da('0x25')]>0x0&&_0x1f6f96[_0x35f687+'CurrentCapacity']>=_0x1f6f96[_0x35f687+_0x62da('0x25')]){writeLog(_0x2fd925,_0x1f6f96,_0x35f687[_0x62da('0x27')]()+_0x62da('0x28'));return![];}}return!![];};exports['showNotification']=function(_0x41de3a,_0x87f92b,_0x438aa5,_0x54da45,_0x4f5657){return sendNotification(!![],_0x41de3a,_0x87f92b,_0x438aa5,_0x54da45,_0x4f5657);};exports[_0x62da('0x29')]=function(_0x301e3d,_0x220ffc,_0x594c5a,_0x45f67a,_0x2a4681){return sendNotification(![],_0x301e3d,_0x220ffc,_0x594c5a,_0x45f67a,_0x2a4681);};exports[_0x62da('0x2a')]=writeLog;