Built motion from commit (unavailable).|2.5.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 _0x77f1=['emit','format','name','user:save','split','\x20interaction','account','notificationSound','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','user:%s','notification:%s','save','remove','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','BUSY','online','OFFLINE','Pause','PAUSE','hasOwnProperty','CurrentCapacity','Capacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','util','../utils','mustache','routing','redis','localhost','socket.io-emitter'];(function(_0x214a25,_0x15071d){var _0x405988=function(_0x5c6fc1){while(--_0x5c6fc1){_0x214a25['push'](_0x214a25['shift']());}};_0x405988(++_0x15071d);}(_0x77f1,0x1dd));var _0x177f=function(_0x1cdb6e,_0x461158){_0x1cdb6e=_0x1cdb6e-0x0;var _0x11f675=_0x77f1[_0x1cdb6e];return _0x11f675;};'use strict';var _=require('lodash');var util=require(_0x177f('0x0'));var utils=require(_0x177f('0x1'));var Mustache=require(_0x177f('0x2'));var Redis=require('ioredis');var config=require('../../../../../config/environment');var logger=require('../../../../../config/logger')(_0x177f('0x3'));config[_0x177f('0x4')]=_['defaults'](config[_0x177f('0x4')],{'host':_0x177f('0x5'),'port':0x18eb});var io=require(_0x177f('0x6'))(new Redis(config[_0x177f('0x4')]));function emit(_0x1bd6b3,_0x58525a,_0x3f43c1){io['to'](_0x1bd6b3)[_0x177f('0x7')](_0x58525a,_0x3f43c1);}function sendNotification(_0x480125,_0xba9371,_0x51a488,_0x2652b4,_0x4e1bab,_0x2050c2){io['to'](util[_0x177f('0x8')]('user:%s',_0x2652b4[_0x177f('0x9')]))[_0x177f('0x7')](_0x177f('0xa'),_0x2652b4);var _0xf5086c=_0x2050c2||{};var _0x233919=_0x51a488[_0x177f('0xb')]('.');var _0x35e9f3={'uniqueid':_0xba9371,'channel':_0x233919[0x0],'id':_0x233919[0x1],'title':_0x233919[0x0]+_0x177f('0xc'),'interactionId':_0x233919[0x2],'queue':_0x4e1bab?_0x4e1bab['name']:null,'sound':_0xf5086c[_0x177f('0xd')][_0x177f('0xe')],'shake':_0xf5086c[_0x177f('0xd')][_0x177f('0xf')]};try{if(!_0xf5086c['body']){_0xf5086c[_0x177f('0x10')]={};}if(_0x4e1bab){_0xf5086c[_0x177f('0x10')][_0x177f('0x11')]=_0x4e1bab;}else if(_0xf5086c['body']['queue']){delete _0xf5086c[_0x177f('0x10')][_0x177f('0x11')];}_0x35e9f3[_0x177f('0x12')]=utils[_0x177f('0x13')](_0xf5086c[_0x177f('0xd')][_0x177f('0x14')],_0xf5086c);}catch(_0x2900de){_0x35e9f3[_0x177f('0x12')]=_0x177f('0x15');logger[_0x177f('0x16')](util['format'](_0x177f('0x17'),_0xba9371,_0x2900de[_0x177f('0x18')]));}io['to'](util['format'](_0x177f('0x19'),_0x2652b4[_0x177f('0x9')]))[_0x177f('0x7')](util[_0x177f('0x8')](_0x177f('0x1a'),_0x480125?_0x177f('0x1b'):_0x177f('0x1c')),_0x35e9f3);}function writeLog(_0x3d3daf,_0x3d48eb,_0x377b95){return logger['info'](util[_0x177f('0x8')](_0x177f('0x1d'),_0x3d3daf,_0x3d48eb[_0x177f('0x9')],_0x377b95));}exports[_0x177f('0x1e')]=function(_0x2880e6,_0x28c762,_0x7adaaf,_0x5eeffa){if(_0x28c762['busy']){writeLog(_0x2880e6,_0x28c762,_0x177f('0x1f'));return![];}if(!_0x28c762[_0x177f('0x20')]){writeLog(_0x2880e6,_0x28c762,_0x177f('0x21'));return![];}if(_0x28c762[_0x7adaaf+_0x177f('0x22')]){writeLog(_0x2880e6,_0x28c762,_0x177f('0x23'));return![];}if(_0x5eeffa&&_0x28c762[_0x177f('0x24')](_0x7adaaf+'Capacity')&&_0x28c762[_0x177f('0x24')](_0x7adaaf+_0x177f('0x25'))){if(_0x28c762[_0x7adaaf+_0x177f('0x26')]>0x0&&_0x28c762[_0x7adaaf+_0x177f('0x25')]>=_0x28c762[_0x7adaaf+_0x177f('0x26')]){writeLog(_0x2880e6,_0x28c762,_0x7adaaf[_0x177f('0x27')]()+_0x177f('0x28'));return![];}}return!![];};exports[_0x177f('0x29')]=function(_0x1ae57e,_0x2a64d7,_0x13f570,_0x3d7f1c,_0x25d876){return sendNotification(!![],_0x1ae57e,_0x2a64d7,_0x13f570,_0x3d7f1c,_0x25d876);};exports[_0x177f('0x2a')]=function(_0xdf7bd,_0x4a1b02,_0xfa8ad0,_0x1df4e4,_0x4b9c40){return sendNotification(![],_0xdf7bd,_0x4a1b02,_0xfa8ad0,_0x1df4e4,_0x4b9c40);};exports[_0x177f('0x2b')]=writeLog;