clean up whep delivery

This commit is contained in:
legop3
2025-11-14 01:45:06 -05:00
parent 31e31bfe2d
commit c0dce561bd
9 changed files with 40 additions and 28 deletions
+5 -22
View File
@@ -36,8 +36,12 @@ async function syncRover(record) {
await removePath(record?.id);
return;
}
const source = normalizeSource(record.meta.media.whepUrl);
const source = record.meta.media.bridgeWhepUrl;
if (!source) {
logger.warn(
'rover %s missing bridgeWhepUrl; video bridge disabled for this rover',
record.id
);
await removePath(record.id);
return;
}
@@ -81,27 +85,6 @@ async function removePath(roverId) {
}
}
function normalizeSource(raw) {
if (!raw) return null;
const trimmed = raw.trim();
if (!trimmed) return null;
try {
const parsed = new URL(/^[a-z]+:\/\//i.test(trimmed) ? trimmed : `http://${trimmed}`);
const protocol = parsed.protocol === 'https:' ? 'wheps' : 'whep';
let path = parsed.pathname || '/';
if (!path.endsWith('/whep')) {
if (!path.endsWith('/')) {
path += '/';
}
path += 'whep';
}
return `${protocol}://${parsed.host}${path}`;
} catch (err) {
logger.warn('invalid WHEP URL: %s (%s)', raw, err.message);
return null;
}
}
async function callApi(method, path, body) {
const url = `${apiBase}${path}`;
const res = await fetch(url, {