summary refs log tree commit diff
path: root/src/activitypub/federation/utils.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-09-26 05:12:01 +0000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-09-26 05:12:01 +0000
commitb64163f7691110060be11559787e603fa33ab505 (patch)
treeb36449a89851f268a94e9bd50c1041cbd176bb24 /src/activitypub/federation/utils.ts
parentfix body parser config (diff)
downloadserver-b64163f7691110060be11559787e603fa33ab505.tar.xz
various things
Diffstat (limited to 'src/activitypub/federation/utils.ts')
-rw-r--r--src/activitypub/federation/utils.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/activitypub/federation/utils.ts b/src/activitypub/federation/utils.ts
index b69bccf4..10a8346e 100644
--- a/src/activitypub/federation/utils.ts
+++ b/src/activitypub/federation/utils.ts
@@ -30,9 +30,14 @@ export const hasAPContext = (data: object) => {
 	return context == activitystreams;
 };
 
-export const resolveAPObject = async <T>(data: string | T): Promise<T> => {
+export const resolveAPObject = async <T extends object>(
+	data: string | T,
+): Promise<T> => {
 	// we were already given an AP object
-	if (typeof data != "string") return data;
+	if (typeof data != "string") {
+		if (!hasAPContext(data)) throw new APError("Object is not APObject");
+		return data;
+	}
 
 	const agent = new ProxyAgent();
 	const ret = await fetch(data, {