Built motion from commit (unavailable).|2.4.6
[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 _0xcd60=['user:%s','name','user:save','\x20interaction','notificationSound','notificationShake','body','queue','msg','getMustacheRender','account','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','format','notification:%s','save','remove','info','isAgentAvailable','busy','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','redis','defaults','localhost','socket.io-emitter','emit'];(function(_0x42c6f8,_0x4c8c5f){var _0x20d16e=function(_0x31ea11){while(--_0x31ea11){_0x42c6f8['push'](_0x42c6f8['shift']());}};_0x20d16e(++_0x4c8c5f);}(_0xcd60,0xf0));var _0x0cd6=function(_0x42a173,_0x38bbc1){_0x42a173=_0x42a173-0x0;var _0x4805b9=_0xcd60[_0x42a173];return _0x4805b9;};'use strict';var _=require(_0x0cd6('0x0'));var util=require(_0x0cd6('0x1'));var utils=require(_0x0cd6('0x2'));var Mustache=require(_0x0cd6('0x3'));var Redis=require(_0x0cd6('0x4'));var config=require(_0x0cd6('0x5'));var logger=require(_0x0cd6('0x6'))('routing');config[_0x0cd6('0x7')]=_[_0x0cd6('0x8')](config[_0x0cd6('0x7')],{'host':_0x0cd6('0x9'),'port':0x18eb});var io=require(_0x0cd6('0xa'))(new Redis(config['redis']));function emit(_0x2ceb47,_0x460833,_0x47c8b2){io['to'](_0x2ceb47)[_0x0cd6('0xb')](_0x460833,_0x47c8b2);}function sendNotification(_0x4fb298,_0x4eae5,_0x253137,_0x14f396,_0x340015,_0x308ebe){io['to'](util['format'](_0x0cd6('0xc'),_0x14f396[_0x0cd6('0xd')]))[_0x0cd6('0xb')](_0x0cd6('0xe'),_0x14f396);var _0x1c10da=_0x308ebe||{};var _0x56acab=_0x253137['split']('.');var _0x8bbba={'uniqueid':_0x4eae5,'channel':_0x56acab[0x0],'id':_0x56acab[0x1],'title':_0x56acab[0x0]+_0x0cd6('0xf'),'interactionId':_0x56acab[0x2],'queue':_0x340015?_0x340015[_0x0cd6('0xd')]:null,'sound':_0x1c10da['account'][_0x0cd6('0x10')],'shake':_0x1c10da['account'][_0x0cd6('0x11')]};try{if(!_0x1c10da[_0x0cd6('0x12')]){_0x1c10da[_0x0cd6('0x12')]={};}if(_0x340015){_0x1c10da[_0x0cd6('0x12')][_0x0cd6('0x13')]=_0x340015;}else if(_0x1c10da[_0x0cd6('0x12')][_0x0cd6('0x13')]){delete _0x1c10da[_0x0cd6('0x12')][_0x0cd6('0x13')];}_0x8bbba[_0x0cd6('0x14')]=utils[_0x0cd6('0x15')](_0x1c10da[_0x0cd6('0x16')][_0x0cd6('0x17')],_0x1c10da);}catch(_0x1b0c3d){_0x8bbba['msg']=_0x0cd6('0x18');logger[_0x0cd6('0x19')](util['format']('[%s][QUEUE]\x20%s',_0x4eae5,_0x1b0c3d['message']));}io['to'](util[_0x0cd6('0x1a')]('user:%s',_0x14f396['name']))[_0x0cd6('0xb')](util['format'](_0x0cd6('0x1b'),_0x4fb298?_0x0cd6('0x1c'):_0x0cd6('0x1d')),_0x8bbba);}function writeLog(_0x1bb2d6,_0xab7f8c,_0x33b228){return logger[_0x0cd6('0x1e')](util[_0x0cd6('0x1a')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0x1bb2d6,_0xab7f8c[_0x0cd6('0xd')],_0x33b228));}exports[_0x0cd6('0x1f')]=function(_0x394a22,_0x4e22f7,_0x55f68f,_0x5cacd5){if(_0x4e22f7[_0x0cd6('0x20')]){writeLog(_0x394a22,_0x4e22f7,'BUSY');return![];}if(!_0x4e22f7['online']){writeLog(_0x394a22,_0x4e22f7,'OFFLINE');return![];}if(_0x4e22f7[_0x55f68f+'Pause']){writeLog(_0x394a22,_0x4e22f7,_0x0cd6('0x21'));return![];}if(_0x5cacd5&&_0x4e22f7[_0x0cd6('0x22')](_0x55f68f+_0x0cd6('0x23'))&&_0x4e22f7[_0x0cd6('0x22')](_0x55f68f+'CurrentCapacity')){if(_0x4e22f7[_0x55f68f+'Capacity']>0x0&&_0x4e22f7[_0x55f68f+_0x0cd6('0x24')]>=_0x4e22f7[_0x55f68f+'Capacity']){writeLog(_0x394a22,_0x4e22f7,_0x55f68f[_0x0cd6('0x25')]()+_0x0cd6('0x26'));return![];}}return!![];};exports[_0x0cd6('0x27')]=function(_0x1d505a,_0x1e75ef,_0x27b771,_0x417f5c,_0x341cee){return sendNotification(!![],_0x1d505a,_0x1e75ef,_0x27b771,_0x417f5c,_0x341cee);};exports[_0x0cd6('0x28')]=function(_0x72c358,_0x1cb053,_0x28d10b,_0x3ab0e7,_0x66e0e2){return sendNotification(![],_0x72c358,_0x1cb053,_0x28d10b,_0x3ab0e7,_0x66e0e2);};exports[_0x0cd6('0x29')]=writeLog;