From 5a7eecdd56120bc29b47ab071c8b8cd16efa3843 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 30 Apr 2020 08:46:40 +0200 Subject: [PATCH] Add config helper for plugins --- server/lib/plugins/plugin-helpers.ts | 14 +++++++++++++- .../plugins/register-server-option.model.ts | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/server/lib/plugins/plugin-helpers.ts b/server/lib/plugins/plugin-helpers.ts index e91beffba..608207e05 100644 --- a/server/lib/plugins/plugin-helpers.ts +++ b/server/lib/plugins/plugin-helpers.ts @@ -2,6 +2,7 @@ import { PeerTubeHelpers } from '@server/typings/plugins' import { sequelizeTypescript } from '@server/initializers/database' import { buildLogger } from '@server/helpers/logger' import { VideoModel } from '@server/models/video/video' +import { WEBSERVER } from '@server/initializers/constants' function buildPluginHelpers (npmName: string): PeerTubeHelpers { const logger = buildPluginLogger(npmName) @@ -9,10 +10,13 @@ function buildPluginHelpers (npmName: string): PeerTubeHelpers { const database = buildDatabaseHelpers() const videos = buildVideosHelpers() + const config = buildConfigHelpers() + return { logger, database, - videos + videos, + config } } @@ -43,3 +47,11 @@ function buildVideosHelpers () { } } } + +function buildConfigHelpers () { + return { + getWebserverUrl () { + return WEBSERVER.URL + } + } +} diff --git a/server/typings/plugins/register-server-option.model.ts b/server/typings/plugins/register-server-option.model.ts index bcabf2fec..c1e63316d 100644 --- a/server/typings/plugins/register-server-option.model.ts +++ b/server/typings/plugins/register-server-option.model.ts @@ -25,6 +25,10 @@ export type PeerTubeHelpers = { videos: { removeVideo: (videoId: number) => Promise } + + config: { + getWebserverUrl: () => string + } } export type RegisterServerOptions = { -- 2.25.1