aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'support/doc/plugins')
-rw-r--r--support/doc/plugins/guide.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 337f3d97f..c5e3236ca 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -16,6 +16,7 @@
16 - [Add external auth methods](#add-external-auth-methods) 16 - [Add external auth methods](#add-external-auth-methods)
17 - [Add new transcoding profiles](#add-new-transcoding-profiles) 17 - [Add new transcoding profiles](#add-new-transcoding-profiles)
18 - [Server helpers](#server-helpers) 18 - [Server helpers](#server-helpers)
19 - [Federation](#federation)
19 - [Client API (themes & plugins)](#client-api-themes--plugins) 20 - [Client API (themes & plugins)](#client-api-themes--plugins)
20 - [Get plugin static and router routes](#get-plugin-static-and-router-routes) 21 - [Get plugin static and router routes](#get-plugin-static-and-router-routes)
21 - [Notifier](#notifier) 22 - [Notifier](#notifier)
@@ -587,6 +588,49 @@ async function register ({
587 588
588See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete helpers list. 589See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete helpers list.
589 590
591#### Federation
592
593You can use some server hooks to federate plugin data to other PeerTube instances that may have installed your plugin.
594
595For example to federate additional video metadata:
596
597```js
598async function register ({ registerHook }) {
599
600 // Send plugin metadata to remote instances
601 // We also update the JSON LD context because we added a new field
602 {
603 registerHook({
604 target: 'filter:activity-pub.video.json-ld.build.result',
605 handler: async (jsonld, { video }) => {
606 return Object.assign(jsonld, { recordedAt: 'https://example.com/event' })
607 }
608 })
609
610 registerHook({
611 target: 'filter:activity-pub.activity.context.build.result',
612 handler: jsonld => {
613 return jsonld.concat([ { recordedAt: 'https://schema.org/recordedAt' } ])
614 }
615 })
616 }
617
618 // Save remote video metadata
619 {
620 for (const h of [ 'action:activity-pub.remote-video.created', 'action:activity-pub.remote-video.updated' ]) {
621 registerHook({
622 target: h,
623 handler: ({ video, videoAPObject }) => {
624 if (videoAPObject.recordedAt) {
625 // Save information about the video
626 }
627 }
628 })
629 }
630 }
631```
632
633
590### Client API (themes & plugins) 634### Client API (themes & plugins)
591 635
592#### Get plugin static and router routes 636#### Get plugin static and router routes