Work on Jitsi settings

This commit is contained in:
Scott Idem
2025-12-02 19:07:55 -05:00
parent b91d79c175
commit 0fcd4e4cdf

View File

@@ -46,36 +46,53 @@
// 1. Function to fetch the JWT from your backend
async function getJitsiJwt() {
// This is the URL of your backend API endpoint.
// It's a server-side route that will create the JWT for you.
const tokenEndpoint = 'https://api.oneskyit.com/api/jitsi_token';
// Pass user information and moderator status to the backend
// This payload now correctly separates features, settings, and config overrides.
// The backend will place these into the correct locations in the JWT.
const payload = {
room: room_name,
name: display_name,
email: email,
is_moderator: is_moderator
is_moderator: is_moderator,
// 'features': For enabling/disabling major Jitsi tools
features: {
livestreaming: false,
recording: false,
transcription: false,
},
// 'settings': For moderator default checkboxes in the settings panel
settings: {
startMuted: true, // Corresponds to "Everyone starts muted"
startHidden: true, // Corresponds to "Everyone starts hidden"
followMe: false, // Corresponds to "Everyone follows me"
reactionsMuted: true // Corresponds to "Mute reaction sounds for everyone"
},
// 'config': For overriding properties from the server's config.js file
config: {
// This disables the reactions feature entirely. If you want reactions to be
// available but just have the sounds muted by default, set this to 'false'.
disableReactions: true,
}
};
console.log('Requesting JWT with payload:', payload);
try {
const response = await fetch(tokenEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error('Failed to fetch JWT token from the server.');
}
if (!response.ok) throw new Error('Failed to fetch JWT token from the server.');
const data = await response.json();
return data.token; // Your backend should return a JSON object like { "token": "..." }
} catch (error) {
console.error('Error getting JWT:', error);
return data.token; // expect { token: "..." }
} catch (err) {
console.error('Error getting JWT:', err);
return null;
}
}
@@ -85,9 +102,7 @@
let jwtToken = null;
if (is_moderator) {
jwtToken = await getJitsiJwt();
if (!jwtToken) {
// Handle the error (e.g., show a message to the user)
document.getElementById('jitsi_meet_external_api_container').innerHTML =
'<h1>Authentication Failed. Please try again.</h1>';
return;
@@ -99,21 +114,24 @@
width: '100%',
height: '100%',
parentNode: document.getElementById('jitsi_meet_external_api_container'),
userInfo: {
displayName: display_name,
email: email
},
userInfo: { displayName: display_name, email: email },
// These settings apply to ALL users. Moderator settings are now in the JWT.
configOverwrite: {
prejoinPageEnabled: false,
startWithAudioMuted: true,
startWithVideoMuted: true,
enablePrejoinPage: false,
enableWelcomePage: false,
enableClosePage: false,
enableLobby: is_moderator
startWithAudioMuted: true, // Mutes the local user upon joining
startWithVideoMuted: true, // Mutes the local user upon joining
enableLobby: is_moderator,
},
// Pass the fetched JWT to the Jitsi API
jwt: jwtToken
interfaceConfigOverwrite: {
DISABLE_JOIN_LEAVE_NOTIFICATIONS: true, // suppress join/leave UI notifications/sounds
// if you want to silence other notification sounds, set any sound URLs to empty:
NOTIFICATION_SOUND_URL: ''
},
jwt: jwtToken // The JWT will correctly override settings for moderators
};
const api = new JitsiMeetExternalAPI(domain, options);