mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 04:03:49 +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(
|
export async function getJsonActivity(
|
||||||
url: string,
|
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,
|
timeout = 10000,
|
||||||
headers?: Record<string, string>,
|
headers?: Record<string, string>,
|
||||||
) {
|
) {
|
||||||
@ -50,8 +50,9 @@ export async function getJsonActivity(
|
|||||||
const contentType = res.headers.get('content-type');
|
const contentType = res.headers.get('content-type');
|
||||||
if (contentType == null ||
|
if (contentType == null ||
|
||||||
(contentType !== 'application/activity+json' && !contentType.startsWith('application/activity+json;') &&
|
(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}`);
|
throw new Error(`getJsonActivity response had unexpected content-type: ${contentType}`);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
finalUrl: res.url,
|
finalUrl: res.url,
|
||||||
|
@ -65,7 +65,7 @@ export function createSignedGet(args: {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
headers: objectAssignWithLcKey(
|
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(),
|
Date: new Date().toUTCString(),
|
||||||
Host: new URL(args.url).hostname,
|
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');
|
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}`);
|
throw new Error(`signedGet response had unexpected content-type: ${contentType}`);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
finalUrl: res.url,
|
finalUrl: res.url,
|
||||||
|
Loading…
Reference in New Issue
Block a user