b1de0db41cc228a2ee5a7092ba2277636155a991
[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 _0x8d0e=['localhost','format','user:%s','emit','user:save','\x20interaction','name','account','notificationSound','body','queue','msg','getMustacheRender','notificationTemplate','error','[%s][QUEUE]\x20%s','notification:%s','save','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults'];(function(_0x36905c,_0xb31581){var _0x5712fb=function(_0x29e126){while(--_0x29e126){_0x36905c['push'](_0x36905c['shift']());}};_0x5712fb(++_0xb31581);}(_0x8d0e,0x1d7));var _0xe8d0=function(_0x1aa42d,_0xa00e80){_0x1aa42d=_0x1aa42d-0x0;var _0x48b4eb=_0x8d0e[_0x1aa42d];return _0x48b4eb;};'use strict';var _=require(_0xe8d0('0x0'));var util=require(_0xe8d0('0x1'));var utils=require(_0xe8d0('0x2'));var Redis=require(_0xe8d0('0x3'));var config=require(_0xe8d0('0x4'));var logger=require(_0xe8d0('0x5'))(_0xe8d0('0x6'));config[_0xe8d0('0x7')]=_[_0xe8d0('0x8')](config['redis'],{'host':_0xe8d0('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function sendNotification(_0x2e2985,_0x92483d,_0x469d37,_0xcc03d0,_0x2b6dce,_0x13aa63){io['to'](util[_0xe8d0('0xa')](_0xe8d0('0xb'),_0xcc03d0['name']))[_0xe8d0('0xc')](_0xe8d0('0xd'),_0xcc03d0);var _0x463159=_0x13aa63||{};var _0x599bc3=_0x469d37['split']('.');var _0x42e0c2={'uniqueid':_0x92483d,'channel':_0x599bc3[0x0],'id':_0x599bc3[0x1],'title':_0x599bc3[0x0]+_0xe8d0('0xe'),'interactionId':_0x599bc3[0x2],'queue':_0x2b6dce?_0x2b6dce[_0xe8d0('0xf')]:null,'sound':_0x463159[_0xe8d0('0x10')][_0xe8d0('0x11')],'shake':_0x463159[_0xe8d0('0x10')]['notificationShake']};try{if(!_0x463159[_0xe8d0('0x12')]){_0x463159[_0xe8d0('0x12')]={};}if(_0x2b6dce){_0x463159['body'][_0xe8d0('0x13')]=_0x2b6dce;}else if(_0x463159['body']['queue']){delete _0x463159[_0xe8d0('0x12')][_0xe8d0('0x13')];}_0x42e0c2[_0xe8d0('0x14')]=utils[_0xe8d0('0x15')](_0x463159[_0xe8d0('0x10')][_0xe8d0('0x16')],_0x463159);}catch(_0x52818a){_0x42e0c2[_0xe8d0('0x14')]='I\x20can\x27t\x20render\x20your\x20template';logger[_0xe8d0('0x17')](util[_0xe8d0('0xa')](_0xe8d0('0x18'),_0x92483d,_0x52818a['message']));}io['to'](util['format']('user:%s',_0xcc03d0[_0xe8d0('0xf')]))[_0xe8d0('0xc')](util[_0xe8d0('0xa')](_0xe8d0('0x19'),_0x2e2985?_0xe8d0('0x1a'):'remove'),_0x42e0c2);}function writeLog(_0x105861,_0x12ebf4,_0x524b00){return logger['debug'](util['format'](_0xe8d0('0x1b'),_0x105861,_0x12ebf4[_0xe8d0('0xf')],_0x524b00));}exports[_0xe8d0('0x1c')]=function(_0x1fbfe8,_0x25f764,_0x23a945,_0x1bd25c){if(_0x25f764[_0xe8d0('0x1d')]){writeLog(_0x1fbfe8,_0x25f764,_0xe8d0('0x1e'));return![];}if(!_0x25f764['online']){writeLog(_0x1fbfe8,_0x25f764,_0xe8d0('0x1f'));return![];}if(_0x25f764[_0x23a945+_0xe8d0('0x20')]){writeLog(_0x1fbfe8,_0x25f764,'PAUSE');return![];}if(_0x1bd25c&&_0x25f764[_0xe8d0('0x21')](_0x23a945+_0xe8d0('0x22'))&&_0x25f764[_0xe8d0('0x21')](_0x23a945+_0xe8d0('0x23'))){if(_0x25f764[_0x23a945+_0xe8d0('0x22')]>0x0&&_0x25f764[_0x23a945+_0xe8d0('0x23')]>=_0x25f764[_0x23a945+_0xe8d0('0x22')]){writeLog(_0x1fbfe8,_0x25f764,_0x23a945[_0xe8d0('0x24')]()+_0xe8d0('0x25'));return![];}}return!![];};exports[_0xe8d0('0x26')]=function(_0x264de4,_0x539548,_0x24982c,_0x26dd52,_0x10dec2){return sendNotification(!![],_0x264de4,_0x539548,_0x24982c,_0x26dd52,_0x10dec2);};exports['hideNotification']=function(_0x10a30b,_0x343b08,_0x526240,_0x1519e2,_0x3ffcb7){return sendNotification(![],_0x10a30b,_0x343b08,_0x526240,_0x1519e2,_0x3ffcb7);};exports[_0xe8d0('0x27')]=writeLog;