a3048b316d5c9eb8a41f4c09cad7adea2fdb2cab
[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 _0x0135=['isAgentAvailable','busy','online','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','routing','defaults','localhost','socket.io-emitter','emit','user:%s','name','user:save','split','\x20interaction','account','notificationShake','body','queue','msg','getMustacheRender','error','[%s][QUEUE]\x20%s','message','notification:%s','remove','info','format','[%s][QUEUE][AGENT:%s][STATUS:%s]'];(function(_0x5d96fe,_0x488626){var _0x170624=function(_0xfe69f){while(--_0xfe69f){_0x5d96fe['push'](_0x5d96fe['shift']());}};_0x170624(++_0x488626);}(_0x0135,0x188));var _0x5013=function(_0xc3d4be,_0x2aa742){_0xc3d4be=_0xc3d4be-0x0;var _0x290bdd=_0x0135[_0xc3d4be];return _0x290bdd;};'use strict';var _=require(_0x5013('0x0'));var util=require(_0x5013('0x1'));var utils=require(_0x5013('0x2'));var Mustache=require(_0x5013('0x3'));var Redis=require('ioredis');var config=require('../../../../../config/environment');var logger=require('../../../../../config/logger')(_0x5013('0x4'));config['redis']=_[_0x5013('0x5')](config['redis'],{'host':_0x5013('0x6'),'port':0x18eb});var io=require(_0x5013('0x7'))(new Redis(config['redis']));function emit(_0x524c20,_0x58a4aa,_0x4a75fd){io['to'](_0x524c20)[_0x5013('0x8')](_0x58a4aa,_0x4a75fd);}function sendNotification(_0x331c6b,_0x42a451,_0x9f9cc1,_0x419a5b,_0x5afc88,_0x5cbc18){io['to'](util['format'](_0x5013('0x9'),_0x419a5b[_0x5013('0xa')]))[_0x5013('0x8')](_0x5013('0xb'),_0x419a5b);var _0x4a6e85=_0x5cbc18||{};var _0x22ec51=_0x9f9cc1[_0x5013('0xc')]('.');var _0x4d3d78={'uniqueid':_0x42a451,'channel':_0x22ec51[0x0],'id':_0x22ec51[0x1],'title':_0x22ec51[0x0]+_0x5013('0xd'),'interactionId':_0x22ec51[0x2],'queue':_0x5afc88?_0x5afc88['name']:null,'sound':_0x4a6e85[_0x5013('0xe')]['notificationSound'],'shake':_0x4a6e85[_0x5013('0xe')][_0x5013('0xf')]};try{if(!_0x4a6e85[_0x5013('0x10')]){_0x4a6e85[_0x5013('0x10')]={};}if(_0x5afc88){_0x4a6e85[_0x5013('0x10')][_0x5013('0x11')]=_0x5afc88;}else if(_0x4a6e85[_0x5013('0x10')][_0x5013('0x11')]){delete _0x4a6e85[_0x5013('0x10')][_0x5013('0x11')];}_0x4d3d78[_0x5013('0x12')]=utils[_0x5013('0x13')](_0x4a6e85[_0x5013('0xe')]['notificationTemplate'],_0x4a6e85);}catch(_0x2c6433){_0x4d3d78['msg']='I\x20can\x27t\x20render\x20your\x20template';logger[_0x5013('0x14')](util['format'](_0x5013('0x15'),_0x42a451,_0x2c6433[_0x5013('0x16')]));}io['to'](util['format']('user:%s',_0x419a5b['name']))[_0x5013('0x8')](util['format'](_0x5013('0x17'),_0x331c6b?'save':_0x5013('0x18')),_0x4d3d78);}function writeLog(_0x20dfc9,_0x807b2d,_0x52f57d){return logger[_0x5013('0x19')](util[_0x5013('0x1a')](_0x5013('0x1b'),_0x20dfc9,_0x807b2d[_0x5013('0xa')],_0x52f57d));}exports[_0x5013('0x1c')]=function(_0xe04338,_0x11f809,_0x24e1cb,_0x46b7b4){if(_0x11f809[_0x5013('0x1d')]){writeLog(_0xe04338,_0x11f809,'BUSY');return![];}if(!_0x11f809[_0x5013('0x1e')]){writeLog(_0xe04338,_0x11f809,_0x5013('0x1f'));return![];}if(_0x11f809[_0x24e1cb+_0x5013('0x20')]){writeLog(_0xe04338,_0x11f809,_0x5013('0x21'));return![];}if(_0x46b7b4&&_0x11f809[_0x5013('0x22')](_0x24e1cb+_0x5013('0x23'))&&_0x11f809[_0x5013('0x22')](_0x24e1cb+_0x5013('0x24'))){if(_0x11f809[_0x24e1cb+_0x5013('0x23')]>0x0&&_0x11f809[_0x24e1cb+_0x5013('0x24')]>=_0x11f809[_0x24e1cb+_0x5013('0x23')]){writeLog(_0xe04338,_0x11f809,_0x24e1cb[_0x5013('0x25')]()+_0x5013('0x26'));return![];}}return!![];};exports[_0x5013('0x27')]=function(_0x1694a7,_0x32b4be,_0x2bee7c,_0x14d4a5,_0x2744d6){return sendNotification(!![],_0x1694a7,_0x32b4be,_0x2bee7c,_0x14d4a5,_0x2744d6);};exports[_0x5013('0x28')]=function(_0xb4a163,_0xc533ad,_0x5b5383,_0x3615b1,_0x149ba0){return sendNotification(![],_0xb4a163,_0xc533ad,_0x5b5383,_0x3615b1,_0x149ba0);};exports[_0x5013('0x29')]=writeLog;