Built motion from commit 746c7d2a.|2.5.35
[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 _0xef17=['emit','format','user:%s','name','\x20interaction','account','notificationSound','notificationShake','body','queue','msg','getMustacheRender','error','save','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','OFFLINE','Pause','Capacity','hasOwnProperty','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','socket.io-emitter'];(function(_0x2b9a84,_0x3f809b){var _0x41692c=function(_0x5a19c5){while(--_0x5a19c5){_0x2b9a84['push'](_0x2b9a84['shift']());}};_0x41692c(++_0x3f809b);}(_0xef17,0x136));var _0x7ef1=function(_0x125d07,_0x399090){_0x125d07=_0x125d07-0x0;var _0x4cbcbe=_0xef17[_0x125d07];return _0x4cbcbe;};'use strict';var _=require(_0x7ef1('0x0'));var util=require(_0x7ef1('0x1'));var utils=require(_0x7ef1('0x2'));var Mustache=require(_0x7ef1('0x3'));var Redis=require(_0x7ef1('0x4'));var config=require(_0x7ef1('0x5'));var logger=require(_0x7ef1('0x6'))(_0x7ef1('0x7'));config[_0x7ef1('0x8')]=_['defaults'](config[_0x7ef1('0x8')],{'host':'localhost','port':0x18eb});var io=require(_0x7ef1('0x9'))(new Redis(config['redis']));function emit(_0x34a040,_0x4ba2f0,_0x5aec63){io['to'](_0x34a040)[_0x7ef1('0xa')](_0x4ba2f0,_0x5aec63);}function sendNotification(_0x3398a6,_0x56ab07,_0xeb10e9,_0x1d5b33,_0x4534fc,_0x3d47e2){io['to'](util[_0x7ef1('0xb')](_0x7ef1('0xc'),_0x1d5b33[_0x7ef1('0xd')]))['emit']('user:save',_0x1d5b33);var _0x1d4522=_0x3d47e2||{};var _0x4dc653=_0xeb10e9['split']('.');var _0x4d60ae={'uniqueid':_0x56ab07,'channel':_0x4dc653[0x0],'id':_0x4dc653[0x1],'title':_0x4dc653[0x0]+_0x7ef1('0xe'),'interactionId':_0x4dc653[0x2],'queue':_0x4534fc?_0x4534fc['name']:null,'sound':_0x1d4522[_0x7ef1('0xf')][_0x7ef1('0x10')],'shake':_0x1d4522[_0x7ef1('0xf')][_0x7ef1('0x11')]};try{if(!_0x1d4522[_0x7ef1('0x12')]){_0x1d4522[_0x7ef1('0x12')]={};}if(_0x4534fc){_0x1d4522[_0x7ef1('0x12')][_0x7ef1('0x13')]=_0x4534fc;}else if(_0x1d4522['body']['queue']){delete _0x1d4522[_0x7ef1('0x12')]['queue'];}_0x4d60ae[_0x7ef1('0x14')]=utils[_0x7ef1('0x15')](_0x1d4522['account']['notificationTemplate'],_0x1d4522);}catch(_0x5d269a){_0x4d60ae[_0x7ef1('0x14')]='I\x20can\x27t\x20render\x20your\x20template';logger[_0x7ef1('0x16')](util['format']('[%s][QUEUE]\x20%s',_0x56ab07,_0x5d269a['message']));}io['to'](util[_0x7ef1('0xb')]('user:%s',_0x1d5b33[_0x7ef1('0xd')]))[_0x7ef1('0xa')](util['format']('notification:%s',_0x3398a6?_0x7ef1('0x17'):'remove'),_0x4d60ae);}function writeLog(_0x458459,_0x33f89b,_0x2f8164){return logger[_0x7ef1('0x18')](util[_0x7ef1('0xb')](_0x7ef1('0x19'),_0x458459,_0x33f89b[_0x7ef1('0xd')],_0x2f8164));}exports[_0x7ef1('0x1a')]=function(_0x490162,_0x2a1bdd,_0x3b118f,_0x3f26fb){if(_0x2a1bdd[_0x7ef1('0x1b')]){writeLog(_0x490162,_0x2a1bdd,_0x7ef1('0x1c'));return![];}if(!_0x2a1bdd[_0x7ef1('0x1d')]){writeLog(_0x490162,_0x2a1bdd,_0x7ef1('0x1e'));return![];}if(_0x2a1bdd[_0x3b118f+_0x7ef1('0x1f')]){writeLog(_0x490162,_0x2a1bdd,'PAUSE');return![];}if(_0x3f26fb&&_0x2a1bdd['hasOwnProperty'](_0x3b118f+_0x7ef1('0x20'))&&_0x2a1bdd[_0x7ef1('0x21')](_0x3b118f+_0x7ef1('0x22'))){if(_0x2a1bdd[_0x3b118f+_0x7ef1('0x20')]>0x0&&_0x2a1bdd[_0x3b118f+_0x7ef1('0x22')]>=_0x2a1bdd[_0x3b118f+'Capacity']){writeLog(_0x490162,_0x2a1bdd,_0x3b118f[_0x7ef1('0x23')]()+_0x7ef1('0x24'));return![];}}return!![];};exports[_0x7ef1('0x25')]=function(_0x4af5f5,_0x232f4e,_0x238fdc,_0x21e8c5,_0x58e7ee){return sendNotification(!![],_0x4af5f5,_0x232f4e,_0x238fdc,_0x21e8c5,_0x58e7ee);};exports[_0x7ef1('0x26')]=function(_0x4b0380,_0x3306b0,_0x2546bf,_0x4b5fde,_0x5f25de){return sendNotification(![],_0x4b0380,_0x3306b0,_0x2546bf,_0x4b5fde,_0x5f25de);};exports[_0x7ef1('0x27')]=writeLog;