Work on Jitsi settings
This commit is contained in:
@@ -46,36 +46,53 @@
|
|||||||
|
|
||||||
// 1. Function to fetch the JWT from your backend
|
// 1. Function to fetch the JWT from your backend
|
||||||
async function getJitsiJwt() {
|
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';
|
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 = {
|
const payload = {
|
||||||
room: room_name,
|
room: room_name,
|
||||||
name: display_name,
|
name: display_name,
|
||||||
email: email,
|
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 {
|
try {
|
||||||
const response = await fetch(tokenEndpoint, {
|
const response = await fetch(tokenEndpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: { 'Content-Type': 'application/json' },
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) throw new Error('Failed to fetch JWT token from the server.');
|
||||||
throw new Error('Failed to fetch JWT token from the server.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data.token; // Your backend should return a JSON object like { "token": "..." }
|
return data.token; // expect { token: "..." }
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
console.error('Error getting JWT:', error);
|
console.error('Error getting JWT:', err);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,9 +102,7 @@
|
|||||||
let jwtToken = null;
|
let jwtToken = null;
|
||||||
if (is_moderator) {
|
if (is_moderator) {
|
||||||
jwtToken = await getJitsiJwt();
|
jwtToken = await getJitsiJwt();
|
||||||
|
|
||||||
if (!jwtToken) {
|
if (!jwtToken) {
|
||||||
// Handle the error (e.g., show a message to the user)
|
|
||||||
document.getElementById('jitsi_meet_external_api_container').innerHTML =
|
document.getElementById('jitsi_meet_external_api_container').innerHTML =
|
||||||
'<h1>Authentication Failed. Please try again.</h1>';
|
'<h1>Authentication Failed. Please try again.</h1>';
|
||||||
return;
|
return;
|
||||||
@@ -99,21 +114,24 @@
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
parentNode: document.getElementById('jitsi_meet_external_api_container'),
|
parentNode: document.getElementById('jitsi_meet_external_api_container'),
|
||||||
userInfo: {
|
userInfo: { displayName: display_name, email: email },
|
||||||
displayName: display_name,
|
|
||||||
email: email
|
// These settings apply to ALL users. Moderator settings are now in the JWT.
|
||||||
},
|
|
||||||
configOverwrite: {
|
configOverwrite: {
|
||||||
prejoinPageEnabled: false,
|
prejoinPageEnabled: false,
|
||||||
startWithAudioMuted: true,
|
startWithAudioMuted: true, // Mutes the local user upon joining
|
||||||
startWithVideoMuted: true,
|
startWithVideoMuted: true, // Mutes the local user upon joining
|
||||||
enablePrejoinPage: false,
|
enableLobby: is_moderator,
|
||||||
enableWelcomePage: false,
|
|
||||||
enableClosePage: false,
|
|
||||||
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);
|
const api = new JitsiMeetExternalAPI(domain, options);
|
||||||
|
|||||||
Reference in New Issue
Block a user