Built motion from commit 9e1399f3.|2.5.37
[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 _0x5334=['error','format','message','save','remove','info','isAgentAvailable','busy','OFFLINE','Pause','PAUSE','Capacity','hasOwnProperty','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/logger','redis','defaults','emit','user:%s','name','user:save','\x20interaction','account','notificationShake','body','queue','getMustacheRender','notificationTemplate','msg'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5334,0x84));var _0x4533=function(_0x3949b0,_0x5ef0f1){_0x3949b0=_0x3949b0-0x0;var _0x4ceff6=_0x5334[_0x3949b0];return _0x4ceff6;};'use strict';var _=require(_0x4533('0x0'));var util=require(_0x4533('0x1'));var utils=require(_0x4533('0x2'));var Mustache=require(_0x4533('0x3'));var Redis=require(_0x4533('0x4'));var config=require('../../../../../config/environment');var logger=require(_0x4533('0x5'))('routing');config[_0x4533('0x6')]=_[_0x4533('0x7')](config['redis'],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x4533('0x6')]));function emit(_0x4dea06,_0x4d89e7,_0x487906){io['to'](_0x4dea06)[_0x4533('0x8')](_0x4d89e7,_0x487906);}function sendNotification(_0x42f94b,_0x300877,_0x2489b6,_0x31018b,_0x21b22f,_0xd417){io['to'](util['format'](_0x4533('0x9'),_0x31018b[_0x4533('0xa')]))[_0x4533('0x8')](_0x4533('0xb'),_0x31018b);var _0x5465bf=_0xd417||{};var _0x7b2420=_0x2489b6['split']('.');var _0xc63e3={'uniqueid':_0x300877,'channel':_0x7b2420[0x0],'id':_0x7b2420[0x1],'title':_0x7b2420[0x0]+_0x4533('0xc'),'interactionId':_0x7b2420[0x2],'queue':_0x21b22f?_0x21b22f[_0x4533('0xa')]:null,'sound':_0x5465bf[_0x4533('0xd')]['notificationSound'],'shake':_0x5465bf[_0x4533('0xd')][_0x4533('0xe')]};try{if(!_0x5465bf[_0x4533('0xf')]){_0x5465bf[_0x4533('0xf')]={};}if(_0x21b22f){_0x5465bf['body'][_0x4533('0x10')]=_0x21b22f;}else if(_0x5465bf['body']['queue']){delete _0x5465bf[_0x4533('0xf')][_0x4533('0x10')];}_0xc63e3['msg']=utils[_0x4533('0x11')](_0x5465bf[_0x4533('0xd')][_0x4533('0x12')],_0x5465bf);}catch(_0x551b0d){_0xc63e3[_0x4533('0x13')]='I\x20can\x27t\x20render\x20your\x20template';logger[_0x4533('0x14')](util[_0x4533('0x15')]('[%s][QUEUE]\x20%s',_0x300877,_0x551b0d[_0x4533('0x16')]));}io['to'](util['format']('user:%s',_0x31018b[_0x4533('0xa')]))[_0x4533('0x8')](util['format']('notification:%s',_0x42f94b?_0x4533('0x17'):_0x4533('0x18')),_0xc63e3);}function writeLog(_0x3467ba,_0x1b08fa,_0x6766eb){return logger[_0x4533('0x19')](util[_0x4533('0x15')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0x3467ba,_0x1b08fa[_0x4533('0xa')],_0x6766eb));}exports[_0x4533('0x1a')]=function(_0x2901f1,_0x4aa438,_0x513011,_0x138fd9){if(_0x4aa438[_0x4533('0x1b')]){writeLog(_0x2901f1,_0x4aa438,'BUSY');return![];}if(!_0x4aa438['online']){writeLog(_0x2901f1,_0x4aa438,_0x4533('0x1c'));return![];}if(_0x4aa438[_0x513011+_0x4533('0x1d')]){writeLog(_0x2901f1,_0x4aa438,_0x4533('0x1e'));return![];}if(_0x138fd9&&_0x4aa438['hasOwnProperty'](_0x513011+_0x4533('0x1f'))&&_0x4aa438[_0x4533('0x20')](_0x513011+_0x4533('0x21'))){if(_0x4aa438[_0x513011+_0x4533('0x1f')]>0x0&&_0x4aa438[_0x513011+_0x4533('0x21')]>=_0x4aa438[_0x513011+_0x4533('0x1f')]){writeLog(_0x2901f1,_0x4aa438,_0x513011[_0x4533('0x22')]()+_0x4533('0x23'));return![];}}return!![];};exports[_0x4533('0x24')]=function(_0x5f16bb,_0x5c1e24,_0xa2e602,_0x5aaf2d,_0x3fd76a){return sendNotification(!![],_0x5f16bb,_0x5c1e24,_0xa2e602,_0x5aaf2d,_0x3fd76a);};exports['hideNotification']=function(_0x159fea,_0x42ba2d,_0x38706b,_0x4300c1,_0x252a44){return sendNotification(![],_0x159fea,_0x42ba2d,_0x38706b,_0x4300c1,_0x252a44);};exports[_0x4533('0x25')]=writeLog;