aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts4
-rw-r--r--server/lib/activitypub/send/send-update.ts2
-rw-r--r--server/models/video/video.ts2
-rw-r--r--server/tests/fixtures/peertube-plugin-test/main.js12
-rw-r--r--server/tests/plugins/filter-hooks.ts17
-rw-r--r--shared/models/plugins/server/server-hook.model.ts2
6 files changed, 34 insertions, 5 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index e3bd5fe71..2bc0e6bb4 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -240,11 +240,11 @@ export class VideoEditComponent implements OnInit, OnDestroy {
240 this.schedulerInterval = setInterval(() => this.minScheduledDate = new Date(), 1000 * 60) // Update every minute 240 this.schedulerInterval = setInterval(() => this.minScheduledDate = new Date(), 1000 * 60) // Update every minute
241 }) 241 })
242 242
243 const updateForm = (values: any) => { 243 const updateFormForPlugins = (values: any) => {
244 this.form.patchValue(values) 244 this.form.patchValue(values)
245 this.cd.detectChanges() 245 this.cd.detectChanges()
246 } 246 }
247 this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.type, updateForm }) 247 this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.type, updateForm: updateFormForPlugins })
248 248
249 this.form.valueChanges.subscribe(() => { 249 this.form.valueChanges.subscribe(() => {
250 this.hooks.runAction('action:video-edit.form.updated', 'video-edit', { type: this.type, formValues: this.form.value }) 250 this.hooks.runAction('action:video-edit.form.updated', 'video-edit', { type: this.type, formValues: this.form.value })
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts
index 5a66294e6..379e2d9d8 100644
--- a/server/lib/activitypub/send/send-update.ts
+++ b/server/lib/activitypub/send/send-update.ts
@@ -59,7 +59,7 @@ async function sendUpdateActor (accountOrChannel: MChannelDefault | MAccountDefa
59 logger.info('Creating job to update actor %s.', byActor.url) 59 logger.info('Creating job to update actor %s.', byActor.url)
60 60
61 const url = getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString()) 61 const url = getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString())
62 const accountOrChannelObject = (accountOrChannel as any).toActivityPubObject() // FIXME: typescript bug? 62 const accountOrChannelObject = await (accountOrChannel as any).toActivityPubObject() // FIXME: typescript bug?
63 const audience = getAudience(byActor) 63 const audience = getAudience(byActor)
64 const updateActivity = buildUpdateActivity(url, byActor, accountOrChannelObject, audience) 64 const updateActivity = buildUpdateActivity(url, byActor, accountOrChannelObject, audience)
65 65
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 7fe2ec293..aa9c62e36 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1717,7 +1717,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1717 toActivityPubObject (this: MVideoAP): Promise<VideoObject> { 1717 toActivityPubObject (this: MVideoAP): Promise<VideoObject> {
1718 return Hooks.wrapObject( 1718 return Hooks.wrapObject(
1719 videoModelToActivityPubObject(this), 1719 videoModelToActivityPubObject(this),
1720 'filter:activity-pub.video.jsonld.build.result', 1720 'filter:activity-pub.video.json-ld.build.result',
1721 { video: this } 1721 { video: this }
1722 ) 1722 )
1723 } 1723 }
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index f01da0226..6d06ec17d 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -208,6 +208,18 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
208 // --------------------------------------------------------------------------- 208 // ---------------------------------------------------------------------------
209 209
210 registerHook({ 210 registerHook({
211 target: 'filter:activity-pub.activity.context.build.result',
212 handler: context => context.concat([ 'https://example.com/new-context' ])
213 })
214
215 registerHook({
216 target: 'filter:activity-pub.video.json-ld.build.result',
217 handler: (jsonld, { video }) => ({ ...jsonld, videoName: video.name })
218 })
219
220 // ---------------------------------------------------------------------------
221
222 registerHook({
211 target: 'filter:api.video-threads.list.params', 223 target: 'filter:api.video-threads.list.params',
212 handler: obj => addToCount(obj) 224 handler: obj => addToCount(obj)
213 }) 225 })
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index a7e052d06..ab3a6a093 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -14,6 +14,7 @@ import {
14 cleanupTests, 14 cleanupTests,
15 createMultipleServers, 15 createMultipleServers,
16 doubleFollow, 16 doubleFollow,
17 makeActivityPubGetRequest,
17 makeGetRequest, 18 makeGetRequest,
18 makeRawRequest, 19 makeRawRequest,
19 PeerTubeServer, 20 PeerTubeServer,
@@ -846,6 +847,22 @@ describe('Test plugin filter hooks', function () {
846 }) 847 })
847 }) 848 })
848 849
850 describe('Activity Pub', function () {
851
852 it('Should run filter:activity-pub.activity.context.build.result', async function () {
853 const { body } = await makeActivityPubGetRequest(servers[0].url, '/w/' + videoUUID)
854 expect(body.type).to.equal('Video')
855
856 expect(body['@context'].some(c => c === 'https://example.com/new-context')).to.be.true
857 })
858
859 it('Should run filter:activity-pub.video.json-ld.build.result', async function () {
860 const { body } = await makeActivityPubGetRequest(servers[0].url, '/w/' + videoUUID)
861 expect(body.name).to.equal('default video 0')
862 expect(body.videoName).to.equal('default video 0')
863 })
864 })
865
849 after(async function () { 866 after(async function () {
850 await cleanupTests(servers) 867 await cleanupTests(servers)
851 }) 868 })
diff --git a/shared/models/plugins/server/server-hook.model.ts b/shared/models/plugins/server/server-hook.model.ts
index 7881beaa2..ca83672d0 100644
--- a/shared/models/plugins/server/server-hook.model.ts
+++ b/shared/models/plugins/server/server-hook.model.ts
@@ -119,7 +119,7 @@ export const serverFilterHookObject = {
119 119
120 // Filter the result of video JSON LD builder 120 // Filter the result of video JSON LD builder
121 // You may also need to use filter:activity-pub.activity.context.build.result to also update JSON LD context 121 // You may also need to use filter:activity-pub.activity.context.build.result to also update JSON LD context
122 'filter:activity-pub.video.jsonld.build.result': true 122 'filter:activity-pub.video.json-ld.build.result': true
123} 123}
124 124
125export type ServerFilterHookName = keyof typeof serverFilterHookObject 125export type ServerFilterHookName = keyof typeof serverFilterHookObject