diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-09 14:51:28 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-04-09 15:17:43 +0200 |
commit | 22820226e54dee61287666a178df2176fafb202a (patch) | |
tree | 3fce30315da83eda4b4f96064ad2703202d0d0f5 /server/lib/plugins | |
parent | 023edc8a54a58d15f8d4f00d7f76e0074d0d3a81 (diff) | |
download | PeerTube-22820226e54dee61287666a178df2176fafb202a.tar.gz PeerTube-22820226e54dee61287666a178df2176fafb202a.tar.zst PeerTube-22820226e54dee61287666a178df2176fafb202a.zip |
Add server plugin helpers
Diffstat (limited to 'server/lib/plugins')
-rw-r--r-- | server/lib/plugins/plugin-helpers-builder.ts | 17 | ||||
-rw-r--r-- | server/lib/plugins/register-helpers.ts | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts index dac6b3185..cbd849742 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/lib/plugins/plugin-helpers-builder.ts | |||
@@ -12,8 +12,10 @@ import { VideoBlacklistCreate } from '@shared/models' | |||
12 | import { blacklistVideo, unblacklistVideo } from '../video-blacklist' | 12 | import { blacklistVideo, unblacklistVideo } from '../video-blacklist' |
13 | import { VideoBlacklistModel } from '@server/models/video/video-blacklist' | 13 | import { VideoBlacklistModel } from '@server/models/video/video-blacklist' |
14 | import { AccountBlocklistModel } from '@server/models/account/account-blocklist' | 14 | import { AccountBlocklistModel } from '@server/models/account/account-blocklist' |
15 | import { getServerConfig } from '../config' | ||
16 | import { MPlugin } from '@server/types/models' | ||
15 | 17 | ||
16 | function buildPluginHelpers (npmName: string): PeerTubeHelpers { | 18 | function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers { |
17 | const logger = buildPluginLogger(npmName) | 19 | const logger = buildPluginLogger(npmName) |
18 | 20 | ||
19 | const database = buildDatabaseHelpers() | 21 | const database = buildDatabaseHelpers() |
@@ -25,12 +27,15 @@ function buildPluginHelpers (npmName: string): PeerTubeHelpers { | |||
25 | 27 | ||
26 | const moderation = buildModerationHelpers() | 28 | const moderation = buildModerationHelpers() |
27 | 29 | ||
30 | const plugin = buildPluginRelatedHelpers(pluginModel) | ||
31 | |||
28 | return { | 32 | return { |
29 | logger, | 33 | logger, |
30 | database, | 34 | database, |
31 | videos, | 35 | videos, |
32 | config, | 36 | config, |
33 | moderation, | 37 | moderation, |
38 | plugin, | ||
34 | server | 39 | server |
35 | } | 40 | } |
36 | } | 41 | } |
@@ -132,6 +137,16 @@ function buildConfigHelpers () { | |||
132 | return { | 137 | return { |
133 | getWebserverUrl () { | 138 | getWebserverUrl () { |
134 | return WEBSERVER.URL | 139 | return WEBSERVER.URL |
140 | }, | ||
141 | |||
142 | getServerConfig () { | ||
143 | return getServerConfig() | ||
135 | } | 144 | } |
136 | } | 145 | } |
137 | } | 146 | } |
147 | |||
148 | function buildPluginRelatedHelpers (plugin: MPlugin) { | ||
149 | return { | ||
150 | getBaseStaticRoute: () => `/plugins/${plugin.name}/${plugin.version}/static/` | ||
151 | } | ||
152 | } | ||
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts index 9b5e1a546..c018e54a8 100644 --- a/server/lib/plugins/register-helpers.ts +++ b/server/lib/plugins/register-helpers.ts | |||
@@ -109,7 +109,7 @@ export class RegisterHelpers { | |||
109 | const unregisterIdAndPassAuth = this.buildUnregisterIdAndPassAuth() | 109 | const unregisterIdAndPassAuth = this.buildUnregisterIdAndPassAuth() |
110 | const unregisterExternalAuth = this.buildUnregisterExternalAuth() | 110 | const unregisterExternalAuth = this.buildUnregisterExternalAuth() |
111 | 111 | ||
112 | const peertubeHelpers = buildPluginHelpers(this.npmName) | 112 | const peertubeHelpers = buildPluginHelpers(this.plugin, this.npmName) |
113 | 113 | ||
114 | return { | 114 | return { |
115 | registerHook, | 115 | registerHook, |