Built motion from commit (unavailable).|2.5.4
[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 _0xe605=['notificationSound','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','[%s][QUEUE]\x20%s','notification:%s','save','remove','isAgentAvailable','busy','online','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','writeLog','lodash','util','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults','localhost','socket.io-emitter','format','user:%s','emit','split','\x20interaction','name','account'];(function(_0xea9d95,_0x1a1003){var _0x12aa1f=function(_0x19abd0){while(--_0x19abd0){_0xea9d95['push'](_0xea9d95['shift']());}};_0x12aa1f(++_0x1a1003);}(_0xe605,0x92));var _0x5e60=function(_0x32bdca,_0x300d5b){_0x32bdca=_0x32bdca-0x0;var _0x4830d0=_0xe605[_0x32bdca];return _0x4830d0;};'use strict';var _=require(_0x5e60('0x0'));var util=require(_0x5e60('0x1'));var utils=require('../utils');var Mustache=require(_0x5e60('0x2'));var Redis=require(_0x5e60('0x3'));var config=require(_0x5e60('0x4'));var logger=require(_0x5e60('0x5'))(_0x5e60('0x6'));config[_0x5e60('0x7')]=_[_0x5e60('0x8')](config[_0x5e60('0x7')],{'host':_0x5e60('0x9'),'port':0x18eb});var io=require(_0x5e60('0xa'))(new Redis(config[_0x5e60('0x7')]));function emit(_0x168a14,_0x4e3501,_0x1c5a6f){io['to'](_0x168a14)['emit'](_0x4e3501,_0x1c5a6f);}function sendNotification(_0x593118,_0x53dccb,_0x43f7eb,_0xe93f9c,_0x150a51,_0x2c5425){io['to'](util[_0x5e60('0xb')](_0x5e60('0xc'),_0xe93f9c['name']))[_0x5e60('0xd')]('user:save',_0xe93f9c);var _0x1d2558=_0x2c5425||{};var _0x15035f=_0x43f7eb[_0x5e60('0xe')]('.');var _0x51e7f6={'uniqueid':_0x53dccb,'channel':_0x15035f[0x0],'id':_0x15035f[0x1],'title':_0x15035f[0x0]+_0x5e60('0xf'),'interactionId':_0x15035f[0x2],'queue':_0x150a51?_0x150a51[_0x5e60('0x10')]:null,'sound':_0x1d2558[_0x5e60('0x11')][_0x5e60('0x12')],'shake':_0x1d2558[_0x5e60('0x11')][_0x5e60('0x13')]};try{if(!_0x1d2558['body']){_0x1d2558[_0x5e60('0x14')]={};}if(_0x150a51){_0x1d2558[_0x5e60('0x14')][_0x5e60('0x15')]=_0x150a51;}else if(_0x1d2558[_0x5e60('0x14')]['queue']){delete _0x1d2558[_0x5e60('0x14')]['queue'];}_0x51e7f6[_0x5e60('0x16')]=utils[_0x5e60('0x17')](_0x1d2558['account'][_0x5e60('0x18')],_0x1d2558);}catch(_0x3e1a44){_0x51e7f6[_0x5e60('0x16')]=_0x5e60('0x19');logger['error'](util[_0x5e60('0xb')](_0x5e60('0x1a'),_0x53dccb,_0x3e1a44['message']));}io['to'](util[_0x5e60('0xb')](_0x5e60('0xc'),_0xe93f9c[_0x5e60('0x10')]))[_0x5e60('0xd')](util[_0x5e60('0xb')](_0x5e60('0x1b'),_0x593118?_0x5e60('0x1c'):_0x5e60('0x1d')),_0x51e7f6);}function writeLog(_0x3282e4,_0x45f1a6,_0x228f13){return logger['info'](util[_0x5e60('0xb')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0x3282e4,_0x45f1a6[_0x5e60('0x10')],_0x228f13));}exports[_0x5e60('0x1e')]=function(_0x2b0bae,_0x144808,_0x34e98d,_0x2a499e){if(_0x144808[_0x5e60('0x1f')]){writeLog(_0x2b0bae,_0x144808,'BUSY');return![];}if(!_0x144808[_0x5e60('0x20')]){writeLog(_0x2b0bae,_0x144808,_0x5e60('0x21'));return![];}if(_0x144808[_0x34e98d+_0x5e60('0x22')]){writeLog(_0x2b0bae,_0x144808,'PAUSE');return![];}if(_0x2a499e&&_0x144808[_0x5e60('0x23')](_0x34e98d+_0x5e60('0x24'))&&_0x144808[_0x5e60('0x23')](_0x34e98d+_0x5e60('0x25'))){if(_0x144808[_0x34e98d+'Capacity']>0x0&&_0x144808[_0x34e98d+_0x5e60('0x25')]>=_0x144808[_0x34e98d+'Capacity']){writeLog(_0x2b0bae,_0x144808,_0x34e98d[_0x5e60('0x26')]()+_0x5e60('0x27'));return![];}}return!![];};exports['showNotification']=function(_0x46691f,_0x19e5ab,_0x5b1b46,_0x1ee931,_0xac9c7a){return sendNotification(!![],_0x46691f,_0x19e5ab,_0x5b1b46,_0x1ee931,_0xac9c7a);};exports['hideNotification']=function(_0x5431a8,_0x52f668,_0xf25956,_0x235cc7,_0x2e8e9e){return sendNotification(![],_0x5431a8,_0x52f668,_0xf25956,_0x235cc7,_0x2e8e9e);};exports[_0x5e60('0x28')]=writeLog;