diff options
author | Chocobozzz <me@florianbigard.com> | 2023-03-16 14:24:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-03-16 14:24:50 +0100 |
commit | 47d883de2efbc2e8b5f6f94ae18c15224cbe982b (patch) | |
tree | 7e89efd42cd7f70656ef9443d0f1e0ae1fc1a659 /support/doc | |
parent | 016b887802aebdb1bada121aa2102f0e0f6e0997 (diff) | |
parent | c3441b0320f632e22318261bcd614d10187de22d (diff) | |
download | PeerTube-47d883de2efbc2e8b5f6f94ae18c15224cbe982b.tar.gz PeerTube-47d883de2efbc2e8b5f6f94ae18c15224cbe982b.tar.zst PeerTube-47d883de2efbc2e8b5f6f94ae18c15224cbe982b.zip |
Merge branch 'release/5.1.0' into develop
Diffstat (limited to 'support/doc')
-rw-r--r-- | support/doc/plugins/guide.md | 44 |
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 | ||
588 | See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete helpers list. | 589 | See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete helpers list. |
589 | 590 | ||
591 | #### Federation | ||
592 | |||
593 | You can use some server hooks to federate plugin data to other PeerTube instances that may have installed your plugin. | ||
594 | |||
595 | For example to federate additional video metadata: | ||
596 | |||
597 | ```js | ||
598 | async 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 |