From b985092289142029ca3882548ab2f72c93398bc4 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Mon, 21 Jul 2025 01:14:47 +0200 Subject: [PATCH] [mirotalksfu] - add global participant limit per room --- .env.template | 8 +++++++- app/src/Room.js | 4 ++++ app/src/Server.js | 7 +++++++ app/src/config.template.js | 18 ++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- public/js/Brand.js | 2 +- public/js/Room.js | 4 ++-- public/js/RoomClient.js | 18 ++++++++++++++++-- 9 files changed, 58 insertions(+), 9 deletions(-) diff --git a/.env.template b/.env.template index 5cf926be..15d54f1f 100644 --- a/.env.template +++ b/.env.template @@ -371,8 +371,14 @@ STATS_ENABLED=true # Enable usage statistics (tru STATS_SRC=https://stats.mirotalk.com/script.js # Stats script URL STATS_ID=41d26670-f275-45bb-af82-3ce91fe57756 # Stats tracking ID +# ----------------------------------------------------- +# 11. Global Moderation Configuration +# ----------------------------------------------------- + +ROOM_MAX_PARTICIPANTS=1000 # Maximum participants per room + # ---------------------------------------------------- -# 11. Mediasoup Configuration +# 12. Mediasoup Configuration # ---------------------------------------------------- MEDIASOUP_ROUTER_AUDIO_LEVEL_OBSERVER_ENABLED=true # Enable audio level observer (true|false) diff --git a/app/src/Room.js b/app/src/Room.js index 9e62b5ab..21b9754d 100644 --- a/app/src/Room.js +++ b/app/src/Room.js @@ -73,6 +73,8 @@ module.exports = class Room { // Share Media this.shareMediaData = {}; + + this.maxParticipants = config?.moderation?.room?.maxParticipants || 1000; } // #################################################### @@ -104,6 +106,8 @@ module.exports = class Room { shareMediaData: this.shareMediaData, dominantSpeaker: this.activeSpeakerObserverEnabled, peers: JSON.stringify([...this.peers]), + maxParticipants: this.maxParticipants, + maxParticipantsReached: this.peers.size > this.maxParticipants, }; } diff --git a/app/src/Server.js b/app/src/Server.js index 46b853d5..b81ffd3f 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -1483,6 +1483,13 @@ function startServer() { redirect: config.features?.redirect?.enabled ? config.features.redirect : false, }, + // Global Moderation & Management + moderation: { + room: { + maxParticipants: config?.moderation?.room?.maxParticipants || 1000, + }, + }, + // Version Information versions: { app: packageJson?.version, diff --git a/app/src/config.template.js b/app/src/config.template.js index 42bb26fe..2f3d2614 100644 --- a/app/src/config.template.js +++ b/app/src/config.template.js @@ -24,6 +24,7 @@ const dotenv = require('dotenv').config(); const packageJson = require('../../package.json'); const os = require('os'); const fs = require('fs'); +const { Moderations } = require('openai/resources/moderations.js'); const splitChar = ','; // ============================================== @@ -1290,6 +1291,23 @@ module.exports = { }, }, + /** + * Global Moderation Settings + * ======================== + * Controls room participant limits and moderation features. + * This section defines how many participants can join a room + * and whether moderation features are enabled. + * Core Settings: + * - maxParticipants: Maximum number of participants allowed in a room + * - moderation: Object containing moderation settings + * - room: Object containing room-specific moderation settings + */ + moderation: { + room: { + maxParticipants: parseInt(process.env.ROOM_MAX_PARTICIPANTS) || 1000, // Maximum participants per room + }, + }, + // ============================================== // 9. Mediasoup (WebRTC) Configuration // ============================================== diff --git a/package-lock.json b/package-lock.json index 50d056e4..c7e1c62a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mirotalksfu", - "version": "1.9.04", + "version": "1.9.05", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mirotalksfu", - "version": "1.9.04", + "version": "1.9.05", "license": "AGPL-3.0", "dependencies": { "@aws-sdk/client-s3": "^3.848.0", diff --git a/package.json b/package.json index 428d9475..1a5542d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalksfu", - "version": "1.9.04", + "version": "1.9.05", "description": "WebRTC SFU browser-based video calls", "main": "Server.js", "scripts": { diff --git a/public/js/Brand.js b/public/js/Brand.js index 04c48688..35bae7e8 100644 --- a/public/js/Brand.js +++ b/public/js/Brand.js @@ -76,7 +76,7 @@ let BRAND = { }, about: { imageUrl: '../images/mirotalk-logo.gif', - title: 'WebRTC SFU v1.9.04', + title: 'WebRTC SFU v1.9.05', html: `