From 9d4c60dccc8e7e777ad139a82e9f61feda9d21fc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Oct 2022 11:07:40 +0200 Subject: Add ability for plugins to register ws routes --- client/src/app/core/plugins/plugin.service.ts | 5 +++++ client/src/standalone/videos/shared/peertube-plugin.ts | 1 + client/src/types/register-client-option.model.ts | 3 +++ 3 files changed, 9 insertions(+) (limited to 'client/src') diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index dadc2a41d..1e79cbf79 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -202,6 +202,11 @@ export class PluginService implements ClientHook { return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/router` }, + getBaseWebSocketRoute: () => { + const pathPrefix = PluginsManager.getPluginPathPrefix(pluginInfo.isTheme) + return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/ws` + }, + getBasePluginClientPath: () => { return '/p' }, diff --git a/client/src/standalone/videos/shared/peertube-plugin.ts b/client/src/standalone/videos/shared/peertube-plugin.ts index 968854ce8..daf6f2b03 100644 --- a/client/src/standalone/videos/shared/peertube-plugin.ts +++ b/client/src/standalone/videos/shared/peertube-plugin.ts @@ -43,6 +43,7 @@ export class PeerTubePlugin { return { getBaseStaticRoute: unimplemented, getBaseRouterRoute: unimplemented, + getBaseWebSocketRoute: unimplemented, getBasePluginClientPath: unimplemented, getSettings: () => { diff --git a/client/src/types/register-client-option.model.ts b/client/src/types/register-client-option.model.ts index 2460a7499..2c09f15a7 100644 --- a/client/src/types/register-client-option.model.ts +++ b/client/src/types/register-client-option.model.ts @@ -24,6 +24,9 @@ export type RegisterClientHelpers = { getBaseRouterRoute: () => string + // PeerTube >= 5.0 + getBaseWebSocketRoute: () => string + getBasePluginClientPath: () => string isLoggedIn: () => boolean -- cgit v1.2.3