diff --git a/.env.template b/.env.template index 0064adb2..4de7bddc 100644 --- a/.env.template +++ b/.env.template @@ -58,6 +58,13 @@ API_KEY_SECRET=mirotalk_default_secret SURVEY_ENABLED=true # true or false SURVEY_URL=https://www.questionpro.com/t/AUs7VZq00L +# Redirect URL on leave room +# Upon leaving the room, users who either opt out of providing feedback or if the survey is disabled +# will be redirected to a specified URL. If enabled false the default '/newrcall' URL will be used. + +REDIRECT_ENABLED=false +REDIRECT_URL='https://p2p.mirotalk.com' + # Sentry (optional) # 1. Goto https://sentry.io/ # 2. Create account diff --git a/app/src/server.js b/app/src/server.js index 99a08535..799127ff 100755 --- a/app/src/server.js +++ b/app/src/server.js @@ -38,7 +38,7 @@ dependencies: { * @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.2.0 + * @version 1.2.1 * */ @@ -140,6 +140,10 @@ const IPLookupEnabled = getEnvBoolean(process.env.IP_LOOKUP_ENABLED); const surveyEnabled = getEnvBoolean(process.env.SURVEY_ENABLED); const surveyURL = process.env.SURVEY_URL || 'https://www.questionpro.com/t/AUs7VZq00L'; +// Redirect URL +const redirectEnabled = getEnvBoolean(process.env.REDIRECT_ENABLED); +const redirectURL = process.env.REDIRECT_URL || '/newcall'; + // Sentry config const Sentry = require('@sentry/node'); const { CaptureConsole } = require('@sentry/integrations'); @@ -505,6 +509,8 @@ async function ngrokStart() { sentry_enabled: sentryEnabled, survey_enabled: surveyEnabled, survey_url: surveyURL, + redirect_enabled: redirectEnabled, + redirect_url: redirectURL, node_version: process.versions.node, }); } catch (err) { @@ -553,6 +559,8 @@ server.listen(port, null, () => { sentry_enabled: sentryEnabled, survey_enabled: surveyEnabled, survey_url: surveyURL, + redirect_enabled: redirectEnabled, + redirect_url: redirectURL, node_version: process.versions.node, }); } @@ -762,6 +770,11 @@ io.sockets.on('connect', async (socket) => { active: surveyEnabled, url: surveyURL, }, + redirect: { + active: redirectEnabled, + url: redirectURL, + } + //... }); }); diff --git a/package.json b/package.json index 585ab14e..7a5a849b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalk", - "version": "1.2.0", + "version": "1.2.1", "description": "A free WebRTC browser-based video call", "main": "server.js", "scripts": { @@ -34,9 +34,9 @@ "license": "AGPL-3.0", "homepage": "https://github.com/miroslavpejic85/mirotalk", "dependencies": { - "@sentry/integrations": "^7.75.0", - "@sentry/node": "^7.75.0", - "axios": "^1.5.1", + "@sentry/integrations": "^7.76.0", + "@sentry/node": "^7.76.0", + "axios": "^1.6.0", "body-parser": "^1.20.2", "colors": "^1.4.0", "compression": "^1.7.4", @@ -45,7 +45,7 @@ "dotenv": "^16.3.1", "express": "^4.18.2", "ngrok": "^4.3.3", - "openai": "^4.13.0", + "openai": "^4.14.0", "qs": "^6.11.2", "socket.io": "^4.7.2", "swagger-ui-express": "^5.0.0", diff --git a/public/js/client.js b/public/js/client.js index 9bb2f35a..b7d007a0 100644 --- a/public/js/client.js +++ b/public/js/client.js @@ -15,7 +15,7 @@ * @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.2.0 + * @version 1.2.1 * */ @@ -634,6 +634,10 @@ const chunkSize = 1024; // 1024 * 16; // 16kb/s let surveyActive = true; // when leaving the room give a feedback, if false will be redirected to newcall page let surveyURL = 'https://www.questionpro.com/t/AUs7VZq00L'; +// Redirect on leave room +let redirectActive = false; +let redirectURL = '/newcall' + /** * Load all Html elements by Id */ @@ -1063,13 +1067,17 @@ async function handleConnect() { * @param {object} config data */ function handleServerInfo(config) { - const { peers_count, is_presenter, survey } = config; + console.log('13. Server info', config); + + const { peers_count, is_presenter, survey, redirect } = config; // Get survey settings from server surveyActive = survey.active; surveyURL = survey.url; - console.log('13. Server info', config); + // Get redirect settings from server + redirectActive = redirect.active, + redirectURL = redirect.url // Limit room to n peers if (userLimits.active && peers_count > userLimits.count) { @@ -9122,11 +9130,11 @@ function showAbout() { * Leave the Room and create a new one */ function leaveRoom() { + checkRecording(); if (surveyActive) { leaveFeedback(); } else { - checkRecording(); - openURL('/newcall'); + redirectOnLeave(); } } @@ -9147,15 +9155,18 @@ function leaveFeedback() { showClass: { popup: 'animate__animated animate__fadeInDown' }, hideClass: { popup: 'animate__animated animate__fadeOutUp' }, }).then((result) => { - checkRecording(); if (result.isConfirmed) { openURL(surveyURL); } else { - openURL('/newcall'); + redirectOnLeave(); } }); } +function redirectOnLeave() { + redirectActive ? openURL(redirectURL) : openURL('/newcall'); +} + /** * Make Obj draggable: https://www.w3schools.com/howto/howto_js_draggable.asp * @param {object} elmnt father element