[mirotalksfu] - fix isPresenter check

هذا الالتزام موجود في:
Miroslav Pejic
2025-04-21 00:58:18 +02:00
الأصل 877f63683d
التزام 01e39a0345
5 ملفات معدلة مع 27 إضافات و23 حذوفات

عرض الملف

@@ -64,7 +64,7 @@ dev dependencies: {
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970 * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com * @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.8.23 * @version 1.8.24
* *
*/ */
@@ -1641,14 +1641,10 @@ function startServer() {
peer_uuid: peer_uuid, peer_uuid: peer_uuid,
is_presenter: is_presenter, is_presenter: is_presenter,
}; };
// first we check if the username match the presenters username // first we check if the username match the presenters username else if join_first enabled
if (hostCfg?.presenters?.list?.includes(peer_name)) { if (hostCfg?.presenters?.list?.includes(peer_name) || (hostCfg?.presenters?.join_first && Object.keys(presenters[socket.room_id]).length === 0)) {
presenter.is_presenter = true;
presenters[socket.room_id][socket.id] = presenter; presenters[socket.room_id][socket.id] = presenter;
} else {
// if not match the presenters username, the first one join room is the presenter
if (Object.keys(presenters[socket.room_id]).length === 0) {
presenters[socket.room_id][socket.id] = presenter;
}
} }
log.info('[Join] - Connected presenters grp by roomId', presenters); log.info('[Join] - Connected presenters grp by roomId', presenters);
@@ -3286,15 +3282,23 @@ function startServer() {
} }
const isPresenter = const isPresenter =
// First condition: join_first validation // 1. Check if join_first mode is enabled and peer matches presenter criteria:
(hostCfg?.presenters?.join_first && // - Presenters list contains the peer's room_id and peer_id
presenters[room_id]?.[peer_id]?.peer_name === peer_name && // - Peer's name and UUID match the stored values
presenters[room_id]?.[peer_id]?.peer_uuid === peer_uuid && // - Presenter object has additional properties (length > 1)
Object.keys(presenters[room_id]?.[peer_id] || {}).length > 1) || (hostCfg?.presenters?.join_first &&
// Fallback condition: list check presenters[room_id]?.[peer_id]?.peer_name === peer_name &&
hostCfg?.presenters?.list?.includes(peer_name) || presenters[room_id]?.[peer_id]?.peer_uuid === peer_uuid &&
// Or from presenters list eg. token... Object.keys(presenters[room_id]?.[peer_id] || {}).length > 1) ||
presenters[room_id]?.[peer_id]?.is_presenter;
// 2. Check if peer_name exists in the static presenters list configuration
hostCfg?.presenters?.list?.includes(peer_name) ||
// 3. Check if peer is explicitly marked as presenter (e.g., from token)
presenters[room_id]?.[peer_id]?.is_presenter ||
// 4. Default case (not a presenter)
false;
log.debug('isPeerPresenter Check', { log.debug('isPeerPresenter Check', {
room_id: room_id, room_id: room_id,

عرض الملف

@@ -1,6 +1,6 @@
{ {
"name": "mirotalksfu", "name": "mirotalksfu",
"version": "1.8.23", "version": "1.8.24",
"description": "WebRTC SFU browser-based video calls", "description": "WebRTC SFU browser-based video calls",
"main": "Server.js", "main": "Server.js",
"scripts": { "scripts": {

عرض الملف

@@ -64,7 +64,7 @@ let BRAND = {
}, },
about: { about: {
imageUrl: '../images/mirotalk-logo.gif', imageUrl: '../images/mirotalk-logo.gif',
title: '<strong>WebRTC SFU v1.8.23</strong>', title: '<strong>WebRTC SFU v1.8.24</strong>',
html: ` html: `
<button <button
id="support-button" id="support-button"

عرض الملف

@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970 * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com * @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.8.23 * @version 1.8.24
* *
*/ */
@@ -5351,7 +5351,7 @@ function showAbout() {
position: 'center', position: 'center',
imageUrl: BRAND.about?.imageUrl && BRAND.about.imageUrl.trim() !== '' ? BRAND.about.imageUrl : image.about, imageUrl: BRAND.about?.imageUrl && BRAND.about.imageUrl.trim() !== '' ? BRAND.about.imageUrl : image.about,
customClass: { image: 'img-about' }, customClass: { image: 'img-about' },
title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.8.23', title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.8.24',
html: ` html: `
<br /> <br />
<div id="about"> <div id="about">

عرض الملف

@@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970 * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com * @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.8.23 * @version 1.8.24
* *
*/ */
@@ -1441,7 +1441,7 @@ class RoomClient {
video: peer_video, video: peer_video,
screen: peer_screen, screen: peer_screen,
notify: 0, notify: 0,
isPresenter: isPresenter, isPresenter: isPresenter || false,
}; };
if (peer_token) queryParams.token = peer_token; if (peer_token) queryParams.token = peer_token;
const url = `${baseUrl}?${Object.entries(queryParams) const url = `${baseUrl}?${Object.entries(queryParams)