Built motion from commit f7863d46.|2.5.41
[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 _0x1883=['[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','online','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','\x20MAXCAPACITY','showNotification','hideNotification','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults','localhost','socket.io-emitter','format','user:%s','name','user:save','\x20interaction','account','notificationSound','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','emit'];(function(_0x50811d,_0x23ca7b){var _0x219c80=function(_0x3e16b7){while(--_0x3e16b7){_0x50811d['push'](_0x50811d['shift']());}};_0x219c80(++_0x23ca7b);}(_0x1883,0xab));var _0x3188=function(_0x3e0b78,_0x1618fd){_0x3e0b78=_0x3e0b78-0x0;var _0x12832f=_0x1883[_0x3e0b78];return _0x12832f;};'use strict';var _=require(_0x3188('0x0'));var util=require(_0x3188('0x1'));var utils=require(_0x3188('0x2'));var Mustache=require(_0x3188('0x3'));var Redis=require(_0x3188('0x4'));var config=require(_0x3188('0x5'));var logger=require(_0x3188('0x6'))(_0x3188('0x7'));config[_0x3188('0x8')]=_[_0x3188('0x9')](config[_0x3188('0x8')],{'host':_0x3188('0xa'),'port':0x18eb});var io=require(_0x3188('0xb'))(new Redis(config[_0x3188('0x8')]));function emit(_0x24f2f1,_0x3ce7fd,_0x3e3afb){io['to'](_0x24f2f1)['emit'](_0x3ce7fd,_0x3e3afb);}function sendNotification(_0x446ab7,_0x2a2f07,_0x53f5c0,_0x2213b5,_0x5b7f47,_0xc6040){io['to'](util[_0x3188('0xc')](_0x3188('0xd'),_0x2213b5[_0x3188('0xe')]))['emit'](_0x3188('0xf'),_0x2213b5);var _0x2cdcb2=_0xc6040||{};var _0x4dcadb=_0x53f5c0['split']('.');var _0x339b4a={'uniqueid':_0x2a2f07,'channel':_0x4dcadb[0x0],'id':_0x4dcadb[0x1],'title':_0x4dcadb[0x0]+_0x3188('0x10'),'interactionId':_0x4dcadb[0x2],'queue':_0x5b7f47?_0x5b7f47[_0x3188('0xe')]:null,'sound':_0x2cdcb2[_0x3188('0x11')][_0x3188('0x12')],'shake':_0x2cdcb2[_0x3188('0x11')]['notificationShake']};try{if(!_0x2cdcb2[_0x3188('0x13')]){_0x2cdcb2['body']={};}if(_0x5b7f47){_0x2cdcb2['body'][_0x3188('0x14')]=_0x5b7f47;}else if(_0x2cdcb2['body']['queue']){delete _0x2cdcb2[_0x3188('0x13')][_0x3188('0x14')];}_0x339b4a[_0x3188('0x15')]=utils[_0x3188('0x16')](_0x2cdcb2[_0x3188('0x11')][_0x3188('0x17')],_0x2cdcb2);}catch(_0x56e302){_0x339b4a[_0x3188('0x15')]=_0x3188('0x18');logger[_0x3188('0x19')](util[_0x3188('0xc')](_0x3188('0x1a'),_0x2a2f07,_0x56e302[_0x3188('0x1b')]));}io['to'](util[_0x3188('0xc')](_0x3188('0xd'),_0x2213b5['name']))[_0x3188('0x1c')](util[_0x3188('0xc')]('notification:%s',_0x446ab7?'save':'remove'),_0x339b4a);}function writeLog(_0x46a318,_0x8b207,_0xd292b5){return logger['info'](util['format'](_0x3188('0x1d'),_0x46a318,_0x8b207[_0x3188('0xe')],_0xd292b5));}exports[_0x3188('0x1e')]=function(_0xaf6a8e,_0xb61717,_0x4bd5ee,_0x30cf2c){if(_0xb61717[_0x3188('0x1f')]){writeLog(_0xaf6a8e,_0xb61717,'BUSY');return![];}if(!_0xb61717[_0x3188('0x20')]){writeLog(_0xaf6a8e,_0xb61717,'OFFLINE');return![];}if(_0xb61717[_0x4bd5ee+'Pause']){writeLog(_0xaf6a8e,_0xb61717,_0x3188('0x21'));return![];}if(_0x30cf2c&&_0xb61717[_0x3188('0x22')](_0x4bd5ee+_0x3188('0x23'))&&_0xb61717[_0x3188('0x22')](_0x4bd5ee+_0x3188('0x24'))){if(_0xb61717[_0x4bd5ee+_0x3188('0x23')]>0x0&&_0xb61717[_0x4bd5ee+_0x3188('0x24')]>=_0xb61717[_0x4bd5ee+_0x3188('0x23')]){writeLog(_0xaf6a8e,_0xb61717,_0x4bd5ee['toUpperCase']()+_0x3188('0x25'));return![];}}return!![];};exports[_0x3188('0x26')]=function(_0x52bb13,_0xd3ee40,_0x14299b,_0x43399d,_0x44db9a){return sendNotification(!![],_0x52bb13,_0xd3ee40,_0x14299b,_0x43399d,_0x44db9a);};exports[_0x3188('0x27')]=function(_0x1f1c6f,_0x8f810f,_0x472926,_0x57c21c,_0x44fa15){return sendNotification(![],_0x1f1c6f,_0x8f810f,_0x472926,_0x57c21c,_0x44fa15);};exports['writeLog']=writeLog;