diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-09-26 05:12:01 +0000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-09-26 05:12:01 +0000 |
commit | b64163f7691110060be11559787e603fa33ab505 (patch) | |
tree | b36449a89851f268a94e9bd50c1041cbd176bb24 /src/activitypub/federation/utils.ts | |
parent | fix body parser config (diff) | |
download | server-b64163f7691110060be11559787e603fa33ab505.tar.xz |
various things
Diffstat (limited to 'src/activitypub/federation/utils.ts')
-rw-r--r-- | src/activitypub/federation/utils.ts | 9 |
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, { |