diff options
author | Chocobozzz <me@florianbigard.com> | 2023-03-10 12:01:21 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-03-10 14:42:18 +0100 |
commit | 866b5d3f5230204d611a556260102996c1aefe10 (patch) | |
tree | d6d1e900ce81a7f1edc121089c10a67abba855eb /server/lib/activitypub/context.ts | |
parent | 4265d90b0061399e23b816e3880ee1be47ead96f (diff) | |
download | PeerTube-866b5d3f5230204d611a556260102996c1aefe10.tar.gz PeerTube-866b5d3f5230204d611a556260102996c1aefe10.tar.zst PeerTube-866b5d3f5230204d611a556260102996c1aefe10.zip |
Add ability for plugins to alter video jsonld
Diffstat (limited to 'server/lib/activitypub/context.ts')
-rw-r--r-- | server/lib/activitypub/context.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/server/lib/activitypub/context.ts b/server/lib/activitypub/context.ts index 349c4d227..a3ca52a31 100644 --- a/server/lib/activitypub/context.ts +++ b/server/lib/activitypub/context.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { ContextType } from '@shared/models' | 1 | import { ContextType } from '@shared/models' |
2 | import { Hooks } from '../plugins/hooks' | ||
2 | 3 | ||
3 | function activityPubContextify <T> (data: T, type: ContextType) { | 4 | async function activityPubContextify <T> (data: T, type: ContextType) { |
4 | return { ...getContextData(type), ...data } | 5 | return { ...await getContextData(type), ...data } |
5 | } | 6 | } |
6 | 7 | ||
7 | // --------------------------------------------------------------------------- | 8 | // --------------------------------------------------------------------------- |
@@ -165,10 +166,13 @@ const contextStore: { [ id in ContextType ]: (string | { [ id: string ]: string | |||
165 | Rate: buildContext() | 166 | Rate: buildContext() |
166 | } | 167 | } |
167 | 168 | ||
168 | function getContextData (type: ContextType) { | 169 | async function getContextData (type: ContextType) { |
169 | return { | 170 | const contextData = await Hooks.wrapObject( |
170 | '@context': contextStore[type] | 171 | contextStore[type], |
171 | } | 172 | 'filter:activity-pub.activity.context.build.result' |
173 | ) | ||
174 | |||
175 | return { '@context': contextData } | ||
172 | } | 176 | } |
173 | 177 | ||
174 | function buildContext (contextValue?: ContextValue) { | 178 | function buildContext (contextValue?: ContextValue) { |