From: Chocobozzz Date: Thu, 30 Apr 2020 06:46:40 +0000 (+0200) Subject: Add config helper for plugins X-Git-Tag: v2.2.0-rc.1~107 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5a7eecdd56120bc29b47ab071c8b8cd16efa3843;p=oweals%2Fpeertube.git Add config helper for plugins --- 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 = {