Built motion from commit ddca4d0d.|2.5.47
[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 _0x5496=['isAgentAvailable','busy','BUSY','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/logger','redis','defaults','emit','format','user:%s','user:save','split','account','notificationSound','notificationShake','body','queue','msg','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','[%s][QUEUE]\x20%s','name','notification:%s','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]'];(function(_0x4ba9e7,_0x1b50d4){var _0x39eb4c=function(_0x5ccd04){while(--_0x5ccd04){_0x4ba9e7['push'](_0x4ba9e7['shift']());}};_0x39eb4c(++_0x1b50d4);}(_0x5496,0x175));var _0x6549=function(_0x1b9233,_0x536c66){_0x1b9233=_0x1b9233-0x0;var _0x41050c=_0x5496[_0x1b9233];return _0x41050c;};'use strict';var _=require(_0x6549('0x0'));var util=require(_0x6549('0x1'));var utils=require(_0x6549('0x2'));var Mustache=require(_0x6549('0x3'));var Redis=require(_0x6549('0x4'));var config=require('../../../../../config/environment');var logger=require(_0x6549('0x5'))('routing');config[_0x6549('0x6')]=_[_0x6549('0x7')](config[_0x6549('0x6')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x6549('0x6')]));function emit(_0x1d8cea,_0x4fcffd,_0x1ca8fc){io['to'](_0x1d8cea)[_0x6549('0x8')](_0x4fcffd,_0x1ca8fc);}function sendNotification(_0x1ef2a6,_0x5c47ba,_0xa12086,_0x35d008,_0x2ecce2,_0x135c2c){io['to'](util[_0x6549('0x9')](_0x6549('0xa'),_0x35d008['name']))['emit'](_0x6549('0xb'),_0x35d008);var _0xac828c=_0x135c2c||{};var _0x3c5f9b=_0xa12086[_0x6549('0xc')]('.');var _0x1a0f72={'uniqueid':_0x5c47ba,'channel':_0x3c5f9b[0x0],'id':_0x3c5f9b[0x1],'title':_0x3c5f9b[0x0]+'\x20interaction','interactionId':_0x3c5f9b[0x2],'queue':_0x2ecce2?_0x2ecce2['name']:null,'sound':_0xac828c[_0x6549('0xd')][_0x6549('0xe')],'shake':_0xac828c['account'][_0x6549('0xf')]};try{if(!_0xac828c[_0x6549('0x10')]){_0xac828c[_0x6549('0x10')]={};}if(_0x2ecce2){_0xac828c[_0x6549('0x10')][_0x6549('0x11')]=_0x2ecce2;}else if(_0xac828c[_0x6549('0x10')]['queue']){delete _0xac828c['body'][_0x6549('0x11')];}_0x1a0f72[_0x6549('0x12')]=utils['getMustacheRender'](_0xac828c[_0x6549('0xd')][_0x6549('0x13')],_0xac828c);}catch(_0x4608fb){_0x1a0f72[_0x6549('0x12')]=_0x6549('0x14');logger['error'](util['format'](_0x6549('0x15'),_0x5c47ba,_0x4608fb['message']));}io['to'](util['format'](_0x6549('0xa'),_0x35d008[_0x6549('0x16')]))[_0x6549('0x8')](util[_0x6549('0x9')](_0x6549('0x17'),_0x1ef2a6?'save':_0x6549('0x18')),_0x1a0f72);}function writeLog(_0x4b40c1,_0x125096,_0x72322b){return logger[_0x6549('0x19')](util[_0x6549('0x9')](_0x6549('0x1a'),_0x4b40c1,_0x125096[_0x6549('0x16')],_0x72322b));}exports[_0x6549('0x1b')]=function(_0x25bc01,_0x2be467,_0x6ae00c,_0x40d3f9){if(_0x2be467[_0x6549('0x1c')]){writeLog(_0x25bc01,_0x2be467,_0x6549('0x1d'));return![];}if(!_0x2be467['online']){writeLog(_0x25bc01,_0x2be467,_0x6549('0x1e'));return![];}if(_0x2be467[_0x6ae00c+_0x6549('0x1f')]){writeLog(_0x25bc01,_0x2be467,'PAUSE');return![];}if(_0x40d3f9&&_0x2be467[_0x6549('0x20')](_0x6ae00c+_0x6549('0x21'))&&_0x2be467[_0x6549('0x20')](_0x6ae00c+'CurrentCapacity')){if(_0x2be467[_0x6ae00c+_0x6549('0x21')]>0x0&&_0x2be467[_0x6ae00c+_0x6549('0x22')]>=_0x2be467[_0x6ae00c+_0x6549('0x21')]){writeLog(_0x25bc01,_0x2be467,_0x6ae00c[_0x6549('0x23')]()+_0x6549('0x24'));return![];}}return!![];};exports[_0x6549('0x25')]=function(_0x2f58f7,_0xa6c718,_0x4c52f1,_0x1794bc,_0x136518){return sendNotification(!![],_0x2f58f7,_0xa6c718,_0x4c52f1,_0x1794bc,_0x136518);};exports[_0x6549('0x26')]=function(_0x4c605c,_0x3f1502,_0x4acaf5,_0x4f0ad1,_0x5aa3a6){return sendNotification(![],_0x4c605c,_0x3f1502,_0x4acaf5,_0x4f0ad1,_0x5aa3a6);};exports[_0x6549('0x27')]=writeLog;