diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/context.ts | 16 | ||||
-rw-r--r-- | server/lib/activitypub/send/http.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-create.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-update.ts | 2 |
4 files changed, 14 insertions, 10 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) { |
diff --git a/server/lib/activitypub/send/http.ts b/server/lib/activitypub/send/http.ts index d8d0b8542..ad7869853 100644 --- a/server/lib/activitypub/send/http.ts +++ b/server/lib/activitypub/send/http.ts | |||
@@ -52,9 +52,9 @@ function buildGlobalHeaders (body: any) { | |||
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | function signAndContextify <T> (byActor: MActor, data: T, contextType: ContextType | null) { | 55 | async function signAndContextify <T> (byActor: MActor, data: T, contextType: ContextType | null) { |
56 | const activity = contextType | 56 | const activity = contextType |
57 | ? activityPubContextify(data, contextType) | 57 | ? await activityPubContextify(data, contextType) |
58 | : data | 58 | : data |
59 | 59 | ||
60 | return signJsonLDObject(byActor, activity) | 60 | return signJsonLDObject(byActor, activity) |
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index 7c3a6bdd0..0e996ab80 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts | |||
@@ -33,7 +33,7 @@ async function sendCreateVideo (video: MVideoAP, transaction: Transaction) { | |||
33 | logger.info('Creating job to send video creation of %s.', video.url, lTags(video.uuid)) | 33 | logger.info('Creating job to send video creation of %s.', video.url, lTags(video.uuid)) |
34 | 34 | ||
35 | const byActor = video.VideoChannel.Account.Actor | 35 | const byActor = video.VideoChannel.Account.Actor |
36 | const videoObject = video.toActivityPubObject() | 36 | const videoObject = await video.toActivityPubObject() |
37 | 37 | ||
38 | const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC) | 38 | const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC) |
39 | const createActivity = buildCreateActivity(video.url, byActor, videoObject, audience) | 39 | const createActivity = buildCreateActivity(video.url, byActor, videoObject, audience) |
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index 24983dd19..5a66294e6 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts | |||
@@ -36,7 +36,7 @@ async function sendUpdateVideo (videoArg: MVideoAPWithoutCaption, transaction: T | |||
36 | video.VideoCaptions = await video.$get('VideoCaptions', { transaction }) | 36 | video.VideoCaptions = await video.$get('VideoCaptions', { transaction }) |
37 | } | 37 | } |
38 | 38 | ||
39 | const videoObject = video.toActivityPubObject() | 39 | const videoObject = await video.toActivityPubObject() |
40 | const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC) | 40 | const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC) |
41 | 41 | ||
42 | const updateActivity = buildUpdateActivity(url, byActor, videoObject, audience) | 42 | const updateActivity = buildUpdateActivity(url, byActor, videoObject, audience) |