mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-21 19:53:50 +01:00
[backend] When fetching activities, specify the acceptable JSON-LD profile explicitly
This commit is contained in:
parent
099ba9ce65
commit
e2cff0340f
@ -30,7 +30,7 @@ export async function getJson(
|
||||
|
||||
export async function getJsonActivity(
|
||||
url: string,
|
||||
accept = "application/activity+json, application/ld+json",
|
||||
accept = "application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"",
|
||||
timeout = 10000,
|
||||
headers?: Record<string, string>,
|
||||
) {
|
||||
@ -50,8 +50,9 @@ export async function getJsonActivity(
|
||||
const contentType = res.headers.get('content-type');
|
||||
if (contentType == null ||
|
||||
(contentType !== 'application/activity+json' && !contentType.startsWith('application/activity+json;') &&
|
||||
(!contentType.startsWith('application/ld+json;') || !contentType.includes('profile="https://www.w3.org/ns/activitystreams"'))))
|
||||
(!contentType.startsWith('application/ld+json;') || !contentType.includes('profile="https://www.w3.org/ns/activitystreams"')))) {
|
||||
throw new Error(`getJsonActivity response had unexpected content-type: ${contentType}`);
|
||||
}
|
||||
|
||||
return {
|
||||
finalUrl: res.url,
|
||||
|
@ -65,7 +65,7 @@ export function createSignedGet(args: {
|
||||
method: "GET",
|
||||
headers: objectAssignWithLcKey(
|
||||
{
|
||||
Accept: "application/activity+json, application/ld+json",
|
||||
Accept: "application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"",
|
||||
Date: new Date().toUTCString(),
|
||||
Host: new URL(args.url).hostname,
|
||||
},
|
||||
|
@ -66,8 +66,11 @@ export async function signedGet(url: string, user: { id: User["id"] }, redirects
|
||||
}
|
||||
|
||||
const contentType = res.headers.get('content-type');
|
||||
if (contentType == null || (contentType !== 'application/activity+json' && !contentType.startsWith('application/activity+json;') && contentType !== 'application/ld+json' && !contentType.startsWith('application/ld+json;')))
|
||||
if (contentType == null ||
|
||||
(contentType !== 'application/activity+json' && !contentType.startsWith('application/activity+json;') &&
|
||||
(!contentType.startsWith('application/ld+json;') || !contentType.includes('profile="https://www.w3.org/ns/activitystreams"')))) {
|
||||
throw new Error(`signedGet response had unexpected content-type: ${contentType}`);
|
||||
}
|
||||
|
||||
return {
|
||||
finalUrl: res.url,
|
||||
|
Loading…
Reference in New Issue
Block a user