atagen

malice

public
Star0
Watch0

Commit 719f7cdd974e

tarball

atagen <boss@atagen.co>2026-10-26 10:41 UTC

1 file changed+6-0
web: stop re-requesting link previews the homeserver refuses

Tuwunel and continuwuity answer 403 to preview_url until an allowlist is configured, and the swallowed error left every render re-asking for the same URL with nothing to show why.
Modified file: web/src/lib/link-previews.ts+6 additions
@@ -17,6 +17,7 @@ export const urlPreviewSettings = writable<UrlPreviewSettings>(DEFAULT_SETTINGS)
1717
1818 const inFlight = new Set<string>();
1919 let backoffUntil = 0;
20+let refusalLogged = false;
2021
2122 export function requestLinkPreview(roomId: string, url: string): void {
2223 if (inFlight.has(url) || url in get(linkPreviews) || Date.now() < backoffUntil) return;
@@ -25,6 +26,11 @@ export function requestLinkPreview(roomId: string, url: string): void {
2526 .then((raw) => linkPreviews.update((all) => ({ ...all, [url]: parseLinkPreview(raw) })))
2627 .catch((e) => {
2728 if (e instanceof ApiError && e.status === 429) backoffUntil = Date.now() + BACKOFF_MS;
29+ else if (e instanceof ApiError && e.status === 403) {
30+ linkPreviews.update((all) => ({ ...all, [url]: null }));
31+ if (!refusalLogged) console.warn('The homeserver refused a link preview', e.message);
32+ refusalLogged = true;
33+ }
2834 })
2935 .finally(() => inFlight.delete(url));
3036 }