From fba8536743a8017ecf78743ccb62f70609a32dab Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 19 Feb 2024 07:50:19 +0100 Subject: [PATCH] stop retries after wrong content-type It does not make sense to re-request the same resource with the same parameters and expect a different content-type to be returned. Also this makes the error message more sensible and understandable. --- packages/backend/src/remote/activitypub/request.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/remote/activitypub/request.ts b/packages/backend/src/remote/activitypub/request.ts index 197f7579b..0bb196250 100644 --- a/packages/backend/src/remote/activitypub/request.ts +++ b/packages/backend/src/remote/activitypub/request.ts @@ -121,9 +121,10 @@ export async function signedGet(_url: string, user: { id: User['id'] }): Promise return false; }; - if (isActivitypub(res.headers.get('Content-Type'))) { - return await res.json(); + if (!isActivitypub(res.headers.get('Content-Type'))) { + throw new Error('invalid response content type'); } + return await res.json(); } }