Saving a mostly working Jitsi update
This commit is contained in:
10
src/app.d.ts
vendored
10
src/app.d.ts
vendored
@@ -14,12 +14,4 @@ declare global {
|
||||
namespace App {
|
||||
interface Platform {}
|
||||
}
|
||||
interface ImportMetaEnv {
|
||||
VITE_NOVI_API_KEY: string;
|
||||
VITE_NOVI_MOD_GROUP_GUID: string;
|
||||
VITE_JITSI_TOKEN_ENDPOINT: string;
|
||||
}
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { ae_loc } from '$lib/stores/ae_stores';
|
||||
|
||||
interface Props {
|
||||
data: any;
|
||||
@@ -16,7 +17,7 @@
|
||||
room_name: string,
|
||||
user_id: string
|
||||
) {
|
||||
const token_endpoint = import.meta.env.VITE_JITSI_TOKEN_ENDPOINT;
|
||||
const token_endpoint = $ae_loc.site_cfg_json?.jitsi_token_endpoint;
|
||||
|
||||
const payload = {
|
||||
name: display_name,
|
||||
@@ -88,7 +89,7 @@
|
||||
}
|
||||
|
||||
// --- Fetch dynamic data from Novi API ---
|
||||
const novi_api_key = import.meta.env.VITE_NOVI_API_KEY;
|
||||
const novi_api_key = $ae_loc.site_cfg_json?.novi_idaa_api_key;
|
||||
const novi_api_headers = new Headers();
|
||||
novi_api_headers.append('Authorization', `Basic ${novi_api_key}`);
|
||||
const requestOptions = {
|
||||
@@ -99,48 +100,59 @@
|
||||
|
||||
try {
|
||||
// Fetch the list of moderators from the Novi group
|
||||
const mod_group_guid = import.meta.env.VITE_NOVI_MOD_GROUP_GUID;
|
||||
const mod_list_url = `https://www.idaa.org/api/groups/${mod_group_guid}/members?pageSize=200`;
|
||||
console.log(`Fetching moderator list from Novi API: ${mod_list_url}`);
|
||||
const mods_response = await fetch(mod_list_url, requestOptions);
|
||||
const novi_idaa_group_guid_li = $ae_loc.site_cfg_json?.novi_idaa_group_guid_li ?? [];
|
||||
let allModeratorsRaw: any[] = [];
|
||||
|
||||
if (mods_response.ok) {
|
||||
const moderatorsRaw = await mods_response.json();
|
||||
console.log('Fetched moderators raw:', moderatorsRaw);
|
||||
if (novi_idaa_group_guid_li.length === 0) {
|
||||
console.warn('Jitsi: novi_idaa_group_guid_li is empty. No moderator groups to check.');
|
||||
}
|
||||
|
||||
// Normalise the payload: support both Array and { Results: Array } shapes
|
||||
let modList: any[] = [];
|
||||
if (Array.isArray(moderatorsRaw)) {
|
||||
modList = moderatorsRaw;
|
||||
} else if (Array.isArray(moderatorsRaw.Results)) {
|
||||
modList = moderatorsRaw.Results;
|
||||
} else if (Array.isArray(moderatorsRaw.Members)) {
|
||||
modList = moderatorsRaw.Members;
|
||||
for (const group_guid of novi_idaa_group_guid_li) {
|
||||
const mod_list_url = `https://www.idaa.org/api/groups/${group_guid}/members?pageSize=200`;
|
||||
console.log(`Jitsi: Fetching moderator list from Novi API for group: ${group_guid}`);
|
||||
const mods_response = await fetch(mod_list_url, requestOptions);
|
||||
|
||||
if (mods_response.ok) {
|
||||
const groupModeratorsRaw = await mods_response.json();
|
||||
// Normalise the payload and combine
|
||||
let groupModList: any[] = [];
|
||||
if (Array.isArray(groupModeratorsRaw)) {
|
||||
groupModList = groupModeratorsRaw;
|
||||
} else if (Array.isArray(groupModeratorsRaw.Results)) {
|
||||
groupModList = groupModeratorsRaw.Results;
|
||||
} else if (Array.isArray(groupModeratorsRaw.Members)) {
|
||||
groupModList = groupModeratorsRaw.Members;
|
||||
} else {
|
||||
console.warn(`Jitsi: Moderator list format is unexpected for group ${group_guid}. Falling back to empty list for this group.`, groupModeratorsRaw);
|
||||
}
|
||||
allModeratorsRaw = allModeratorsRaw.concat(groupModList);
|
||||
console.log(`Jitsi: Fetched ${groupModList.length} moderators from group ${group_guid}. Total: ${allModeratorsRaw.length}`);
|
||||
} else {
|
||||
console.warn('Moderator list format is unexpected. Falling back to empty list.', moderatorsRaw);
|
||||
modList = [];
|
||||
console.warn(`Jitsi: Could not fetch moderator list from Novi API for group: ${group_guid}. Status: ${mods_response.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Build a set of normalized IDs from a few possible fields
|
||||
const modIdSet = new Set(
|
||||
modList
|
||||
.map((m: any) => (m?.UniqueID ?? m?.UniqueId ?? m?.DuesPayerUniqueID ?? m?.id ?? ''))
|
||||
.filter(Boolean)
|
||||
.map((id: string) => id.toLowerCase().trim())
|
||||
);
|
||||
if (allModeratorsRaw.length === 0) {
|
||||
console.warn('Jitsi: No moderators fetched across all specified Novi groups. Falling back to empty list.');
|
||||
}
|
||||
console.log('Jitsi: Fetched all moderators raw (combined):', allModeratorsRaw);
|
||||
|
||||
const normalizedUserId = String(user_id ?? '').toLowerCase().trim();
|
||||
// Build a set of normalized IDs from a few possible fields using allModeratorsRaw
|
||||
const modIdSet = new Set(
|
||||
allModeratorsRaw
|
||||
.map((m: any) => (m?.UniqueID ?? m?.UniqueId ?? m?.DuesPayerUniqueID ?? m?.id ?? ''))
|
||||
.filter(Boolean)
|
||||
.map((id: string) => id.toLowerCase().trim())
|
||||
);
|
||||
|
||||
console.log(`Moderator IDs (${modIdSet.size}) sample:`, Array.from(modIdSet).slice(0, 10));
|
||||
if (normalizedUserId && modIdSet.has(normalizedUserId)) {
|
||||
is_moderator = true;
|
||||
console.log(`User ${user_id} is a moderator (matched by UniqueID).`);
|
||||
} else {
|
||||
// Also check by matching name/email if needed (optional)
|
||||
console.log(`User ${user_id} is not a moderator.`);
|
||||
}
|
||||
const normalizedUserId = String(user_id ?? '').toLowerCase().trim();
|
||||
|
||||
console.log(`Jitsi: Moderator IDs (${modIdSet.size}) sample:`, Array.from(modIdSet).slice(0, 10));
|
||||
if (normalizedUserId && modIdSet.has(normalizedUserId)) {
|
||||
is_moderator = true;
|
||||
console.log(`Jitsi: User ${user_id} is a moderator (matched by UniqueID).`);
|
||||
} else {
|
||||
console.warn('Could not fetch moderator list from Novi API.');
|
||||
console.log(`Jitsi: User ${user_id} is not a moderator.`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Jitsi: Error fetching data from Novi API:', error);
|
||||
|
||||
@@ -39,10 +39,12 @@
|
||||
let start_hidden = true; // "Everyone starts hidden"
|
||||
let reactions_muted = true; // "Mute reaction sounds for everyone"
|
||||
|
||||
let idaa_osit_site_key = '8VTOJ0X5hvT6JdiTJsGEzQ'; // 'restricted-access'
|
||||
// let idaa_ae_api_root_url = 'https://sk-idaa.oneskyit.com/idaa/jitsi_meet';
|
||||
let idaa_ae_api_root_url =
|
||||
'https://static.oneskyit.com/c/DgrZone/jitsi_iframe_api_testing.html';
|
||||
// Do *not* use relative paths here. They must be direct to the site I am hosting for IDAA.
|
||||
// 'https://sk-idaa.oneskyit.com/idaa/video_conferences' OR 'https://dev-idaa.oneskyit.com/idaa/video_conferences' OR 'http://idaa.localhost:5173/idaa/video_conferences'
|
||||
// let idaa_osit_ae_api_root_url = 'https://sk-idaa.oneskyit.com/idaa/jitsi_meet';
|
||||
let idaa_osit_ae_api_root_url =
|
||||
'https://static.oneskyit.com/c/DgrZone/jitsi_iframe_api_testing.html'; // Point to the Svelte Jitsi page
|
||||
let idaa_osit_ae_site_key = '8VTOJ0X5hvT6JdiTJsGEzQ'; // 'restricted-access'
|
||||
let idaa_ae_params = new URLSearchParams(document.location.search);
|
||||
// let idaa_ae_slct_event_id = idaa_ae_params.get('event_id');
|
||||
|
||||
@@ -83,7 +85,7 @@
|
||||
);
|
||||
|
||||
idaa_ae_iframe_element.src =
|
||||
`${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${full_name}&moderator=${is_moderator}&room=${room_name}&iframe=true&key=${idaa_osit_site_key}&incoming_msg_sound=${incoming_msg_sound}&participant_joined_sound=${participant_joined_sound}&participant_left_sound=${participant_left_sound}&reaction_sound=${reaction_sound}&raise_hand_sound=${raise_hand_sound}&start_muted=${start_muted}&start_hidden=${start_hidden}&reactions_muted=${reactions_muted}`
|
||||
`${idaa_osit_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${full_name}&moderator=${is_moderator}&room=${room_name}&iframe=true&key=${idaa_osit_ae_site_key}&incoming_msg_sound=${incoming_msg_sound}&participant_joined_sound=${participant_joined_sound}&participant_left_sound=${participant_left_sound}&reaction_sound=${reaction_sound}&raise_hand_sound=${raise_hand_sound}&start_muted=${start_muted}&start_hidden=${start_hidden}&reactions_muted=${reactions_muted}`
|
||||
;
|
||||
|
||||
// url.searchParams.delete('event_id');
|
||||
|
||||
Reference in New Issue
Block a user