Add server plugin helpers

This commit is contained in:
Chocobozzz 2021-04-09 14:51:28 +02:00
parent 023edc8a54
commit 22820226e5
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
9 changed files with 326 additions and 249 deletions

View File

@ -1,24 +1,17 @@
import { Hooks } from '@server/lib/plugins/hooks'
import * as express from 'express' import * as express from 'express'
import { remove, writeJSON } from 'fs-extra' import { remove, writeJSON } from 'fs-extra'
import { snakeCase } from 'lodash' import { snakeCase } from 'lodash'
import validator from 'validator' import validator from 'validator'
import { RegisteredExternalAuthConfig, RegisteredIdAndPassAuthConfig, ServerConfig, UserRight } from '../../../shared' import { getServerConfig } from '@server/lib/config'
import { UserRight } from '../../../shared'
import { About } from '../../../shared/models/server/about.model' import { About } from '../../../shared/models/server/about.model'
import { CustomConfig } from '../../../shared/models/server/custom-config.model' import { CustomConfig } from '../../../shared/models/server/custom-config.model'
import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger' import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger'
import { objectConverter } from '../../helpers/core-utils' import { objectConverter } from '../../helpers/core-utils'
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' import { CONFIG, reloadConfig } from '../../initializers/config'
import { getServerCommit } from '../../helpers/utils'
import { getEnabledResolutions } from '../../lib/video-transcoding'
import { CONFIG, isEmailEnabled, reloadConfig } from '../../initializers/config'
import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '../../initializers/constants'
import { ClientHtml } from '../../lib/client-html' import { ClientHtml } from '../../lib/client-html'
import { PluginManager } from '../../lib/plugins/plugin-manager'
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
import { customConfigUpdateValidator } from '../../middlewares/validators/config' import { customConfigUpdateValidator } from '../../middlewares/validators/config'
import { VideoTranscodingProfilesManager } from '@server/lib/video-transcoding-profiles'
const configRouter = express.Router() const configRouter = express.Router()
@ -46,182 +39,8 @@ configRouter.delete('/custom',
asyncMiddleware(deleteCustomConfig) asyncMiddleware(deleteCustomConfig)
) )
let serverCommit: string
async function getConfig (req: express.Request, res: express.Response) { async function getConfig (req: express.Request, res: express.Response) {
const { allowed } = await Hooks.wrapPromiseFun( const json = await getServerConfig(req.ip)
isSignupAllowed,
{
ip: req.ip
},
'filter:api.user.signup.allowed.result'
)
const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
if (serverCommit === undefined) serverCommit = await getServerCommit()
const json: ServerConfig = {
instance: {
name: CONFIG.INSTANCE.NAME,
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
isNSFW: CONFIG.INSTANCE.IS_NSFW,
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
customizations: {
javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT,
css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS
}
},
search: {
remoteUri: {
users: CONFIG.SEARCH.REMOTE_URI.USERS,
anonymous: CONFIG.SEARCH.REMOTE_URI.ANONYMOUS
},
searchIndex: {
enabled: CONFIG.SEARCH.SEARCH_INDEX.ENABLED,
url: CONFIG.SEARCH.SEARCH_INDEX.URL,
disableLocalSearch: CONFIG.SEARCH.SEARCH_INDEX.DISABLE_LOCAL_SEARCH,
isDefaultSearch: CONFIG.SEARCH.SEARCH_INDEX.IS_DEFAULT_SEARCH
}
},
plugin: {
registered: getRegisteredPlugins(),
registeredExternalAuths: getExternalAuthsPlugins(),
registeredIdAndPassAuths: getIdAndPassAuthPlugins()
},
theme: {
registered: getRegisteredThemes(),
default: defaultTheme
},
email: {
enabled: isEmailEnabled()
},
contactForm: {
enabled: CONFIG.CONTACT_FORM.ENABLED
},
serverVersion: PEERTUBE_VERSION,
serverCommit,
signup: {
allowed,
allowedForCurrentIP,
requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION
},
transcoding: {
hls: {
enabled: CONFIG.TRANSCODING.HLS.ENABLED
},
webtorrent: {
enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
},
enabledResolutions: getEnabledResolutions('vod'),
profile: CONFIG.TRANSCODING.PROFILE,
availableProfiles: VideoTranscodingProfilesManager.Instance.getAvailableProfiles('vod')
},
live: {
enabled: CONFIG.LIVE.ENABLED,
allowReplay: CONFIG.LIVE.ALLOW_REPLAY,
maxDuration: CONFIG.LIVE.MAX_DURATION,
maxInstanceLives: CONFIG.LIVE.MAX_INSTANCE_LIVES,
maxUserLives: CONFIG.LIVE.MAX_USER_LIVES,
transcoding: {
enabled: CONFIG.LIVE.TRANSCODING.ENABLED,
enabledResolutions: getEnabledResolutions('live'),
profile: CONFIG.LIVE.TRANSCODING.PROFILE,
availableProfiles: VideoTranscodingProfilesManager.Instance.getAvailableProfiles('live')
},
rtmp: {
port: CONFIG.LIVE.RTMP.PORT
}
},
import: {
videos: {
http: {
enabled: CONFIG.IMPORT.VIDEOS.HTTP.ENABLED
},
torrent: {
enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED
}
}
},
autoBlacklist: {
videos: {
ofUsers: {
enabled: CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED
}
}
},
avatar: {
file: {
size: {
max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
},
extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
}
},
banner: {
file: {
size: {
max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
},
extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
}
},
video: {
image: {
extensions: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME,
size: {
max: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max
}
},
file: {
extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME
}
},
videoCaption: {
file: {
size: {
max: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max
},
extensions: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME
}
},
user: {
videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
},
trending: {
videos: {
intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS,
algorithms: {
enabled: CONFIG.TRENDING.VIDEOS.ALGORITHMS.ENABLED,
default: CONFIG.TRENDING.VIDEOS.ALGORITHMS.DEFAULT
}
}
},
tracker: {
enabled: CONFIG.TRACKER.ENABLED
},
followings: {
instance: {
autoFollowIndex: {
indexUrl: CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.INDEX_URL
}
}
},
broadcastMessage: {
enabled: CONFIG.BROADCAST_MESSAGE.ENABLED,
message: CONFIG.BROADCAST_MESSAGE.MESSAGE,
level: CONFIG.BROADCAST_MESSAGE.LEVEL,
dismissable: CONFIG.BROADCAST_MESSAGE.DISMISSABLE
}
}
return res.json(json) return res.json(json)
} }
@ -292,69 +111,10 @@ async function updateCustomConfig (req: express.Request, res: express.Response)
return res.json(data) return res.json(data)
} }
function getRegisteredThemes () {
return PluginManager.Instance.getRegisteredThemes()
.map(t => ({
name: t.name,
version: t.version,
description: t.description,
css: t.css,
clientScripts: t.clientScripts
}))
}
function getRegisteredPlugins () {
return PluginManager.Instance.getRegisteredPlugins()
.map(p => ({
name: p.name,
version: p.version,
description: p.description,
clientScripts: p.clientScripts
}))
}
function getIdAndPassAuthPlugins () {
const result: RegisteredIdAndPassAuthConfig[] = []
for (const p of PluginManager.Instance.getIdAndPassAuths()) {
for (const auth of p.idAndPassAuths) {
result.push({
npmName: p.npmName,
name: p.name,
version: p.version,
authName: auth.authName,
weight: auth.getWeight()
})
}
}
return result
}
function getExternalAuthsPlugins () {
const result: RegisteredExternalAuthConfig[] = []
for (const p of PluginManager.Instance.getExternalAuths()) {
for (const auth of p.externalAuths) {
result.push({
npmName: p.npmName,
name: p.name,
version: p.version,
authName: auth.authName,
authDisplayName: auth.authDisplayName()
})
}
}
return result
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
export { export {
configRouter, configRouter
getRegisteredPlugins,
getRegisteredThemes
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -1,8 +1,8 @@
import * as cors from 'cors' import * as cors from 'cors'
import * as express from 'express' import * as express from 'express'
import { join } from 'path' import { join } from 'path'
import { getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config'
import { serveIndexHTML } from '@server/lib/client-html' import { serveIndexHTML } from '@server/lib/client-html'
import { getRegisteredPlugins, getRegisteredThemes } from '@server/lib/config'
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo'
import { root } from '../helpers/core-utils' import { root } from '../helpers/core-utils'

View File

@ -20,6 +20,8 @@ async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: st
} }
function isSignupAllowedForCurrentIP (ip: string) { function isSignupAllowedForCurrentIP (ip: string) {
if (!ip) return false
const addr = ipaddr.parse(ip) const addr = ipaddr.parse(ip)
const excludeList = [ 'blacklist' ] const excludeList = [ 'blacklist' ]
let matched = '' let matched = ''

255
server/lib/config.ts Normal file
View File

@ -0,0 +1,255 @@
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/helpers/signup'
import { getServerCommit } from '@server/helpers/utils'
import { CONFIG, isEmailEnabled } from '@server/initializers/config'
import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants'
import { RegisteredExternalAuthConfig, RegisteredIdAndPassAuthConfig, ServerConfig } from '@shared/models'
import { Hooks } from './plugins/hooks'
import { PluginManager } from './plugins/plugin-manager'
import { getThemeOrDefault } from './plugins/theme-utils'
import { getEnabledResolutions } from './video-transcoding'
import { VideoTranscodingProfilesManager } from './video-transcoding-profiles'
let serverCommit: string
async function getServerConfig (ip?: string): Promise<ServerConfig> {
if (serverCommit === undefined) serverCommit = await getServerCommit()
const { allowed } = await Hooks.wrapPromiseFun(
isSignupAllowed,
{
ip
},
'filter:api.user.signup.allowed.result'
)
const allowedForCurrentIP = isSignupAllowedForCurrentIP(ip)
const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
return {
instance: {
name: CONFIG.INSTANCE.NAME,
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
isNSFW: CONFIG.INSTANCE.IS_NSFW,
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
customizations: {
javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT,
css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS
}
},
search: {
remoteUri: {
users: CONFIG.SEARCH.REMOTE_URI.USERS,
anonymous: CONFIG.SEARCH.REMOTE_URI.ANONYMOUS
},
searchIndex: {
enabled: CONFIG.SEARCH.SEARCH_INDEX.ENABLED,
url: CONFIG.SEARCH.SEARCH_INDEX.URL,
disableLocalSearch: CONFIG.SEARCH.SEARCH_INDEX.DISABLE_LOCAL_SEARCH,
isDefaultSearch: CONFIG.SEARCH.SEARCH_INDEX.IS_DEFAULT_SEARCH
}
},
plugin: {
registered: getRegisteredPlugins(),
registeredExternalAuths: getExternalAuthsPlugins(),
registeredIdAndPassAuths: getIdAndPassAuthPlugins()
},
theme: {
registered: getRegisteredThemes(),
default: defaultTheme
},
email: {
enabled: isEmailEnabled()
},
contactForm: {
enabled: CONFIG.CONTACT_FORM.ENABLED
},
serverVersion: PEERTUBE_VERSION,
serverCommit,
signup: {
allowed,
allowedForCurrentIP,
requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION
},
transcoding: {
hls: {
enabled: CONFIG.TRANSCODING.HLS.ENABLED
},
webtorrent: {
enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
},
enabledResolutions: getEnabledResolutions('vod'),
profile: CONFIG.TRANSCODING.PROFILE,
availableProfiles: VideoTranscodingProfilesManager.Instance.getAvailableProfiles('vod')
},
live: {
enabled: CONFIG.LIVE.ENABLED,
allowReplay: CONFIG.LIVE.ALLOW_REPLAY,
maxDuration: CONFIG.LIVE.MAX_DURATION,
maxInstanceLives: CONFIG.LIVE.MAX_INSTANCE_LIVES,
maxUserLives: CONFIG.LIVE.MAX_USER_LIVES,
transcoding: {
enabled: CONFIG.LIVE.TRANSCODING.ENABLED,
enabledResolutions: getEnabledResolutions('live'),
profile: CONFIG.LIVE.TRANSCODING.PROFILE,
availableProfiles: VideoTranscodingProfilesManager.Instance.getAvailableProfiles('live')
},
rtmp: {
port: CONFIG.LIVE.RTMP.PORT
}
},
import: {
videos: {
http: {
enabled: CONFIG.IMPORT.VIDEOS.HTTP.ENABLED
},
torrent: {
enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED
}
}
},
autoBlacklist: {
videos: {
ofUsers: {
enabled: CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED
}
}
},
avatar: {
file: {
size: {
max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
},
extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
}
},
banner: {
file: {
size: {
max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
},
extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
}
},
video: {
image: {
extensions: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME,
size: {
max: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max
}
},
file: {
extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME
}
},
videoCaption: {
file: {
size: {
max: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max
},
extensions: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME
}
},
user: {
videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
},
trending: {
videos: {
intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS,
algorithms: {
enabled: CONFIG.TRENDING.VIDEOS.ALGORITHMS.ENABLED,
default: CONFIG.TRENDING.VIDEOS.ALGORITHMS.DEFAULT
}
}
},
tracker: {
enabled: CONFIG.TRACKER.ENABLED
},
followings: {
instance: {
autoFollowIndex: {
indexUrl: CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.INDEX_URL
}
}
},
broadcastMessage: {
enabled: CONFIG.BROADCAST_MESSAGE.ENABLED,
message: CONFIG.BROADCAST_MESSAGE.MESSAGE,
level: CONFIG.BROADCAST_MESSAGE.LEVEL,
dismissable: CONFIG.BROADCAST_MESSAGE.DISMISSABLE
}
}
}
function getRegisteredThemes () {
return PluginManager.Instance.getRegisteredThemes()
.map(t => ({
name: t.name,
version: t.version,
description: t.description,
css: t.css,
clientScripts: t.clientScripts
}))
}
function getRegisteredPlugins () {
return PluginManager.Instance.getRegisteredPlugins()
.map(p => ({
name: p.name,
version: p.version,
description: p.description,
clientScripts: p.clientScripts
}))
}
// ---------------------------------------------------------------------------
export {
getServerConfig,
getRegisteredThemes,
getRegisteredPlugins
}
// ---------------------------------------------------------------------------
function getIdAndPassAuthPlugins () {
const result: RegisteredIdAndPassAuthConfig[] = []
for (const p of PluginManager.Instance.getIdAndPassAuths()) {
for (const auth of p.idAndPassAuths) {
result.push({
npmName: p.npmName,
name: p.name,
version: p.version,
authName: auth.authName,
weight: auth.getWeight()
})
}
}
return result
}
function getExternalAuthsPlugins () {
const result: RegisteredExternalAuthConfig[] = []
for (const p of PluginManager.Instance.getExternalAuths()) {
for (const auth of p.externalAuths) {
result.push({
npmName: p.npmName,
name: p.name,
version: p.version,
authName: auth.authName,
authDisplayName: auth.authDisplayName()
})
}
}
return result
}

View File

@ -12,8 +12,10 @@ import { VideoBlacklistCreate } from '@shared/models'
import { blacklistVideo, unblacklistVideo } from '../video-blacklist' import { blacklistVideo, unblacklistVideo } from '../video-blacklist'
import { VideoBlacklistModel } from '@server/models/video/video-blacklist' import { VideoBlacklistModel } from '@server/models/video/video-blacklist'
import { AccountBlocklistModel } from '@server/models/account/account-blocklist' import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
import { getServerConfig } from '../config'
import { MPlugin } from '@server/types/models'
function buildPluginHelpers (npmName: string): PeerTubeHelpers { function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers {
const logger = buildPluginLogger(npmName) const logger = buildPluginLogger(npmName)
const database = buildDatabaseHelpers() const database = buildDatabaseHelpers()
@ -25,12 +27,15 @@ function buildPluginHelpers (npmName: string): PeerTubeHelpers {
const moderation = buildModerationHelpers() const moderation = buildModerationHelpers()
const plugin = buildPluginRelatedHelpers(pluginModel)
return { return {
logger, logger,
database, database,
videos, videos,
config, config,
moderation, moderation,
plugin,
server server
} }
} }
@ -132,6 +137,16 @@ function buildConfigHelpers () {
return { return {
getWebserverUrl () { getWebserverUrl () {
return WEBSERVER.URL return WEBSERVER.URL
},
getServerConfig () {
return getServerConfig()
} }
} }
} }
function buildPluginRelatedHelpers (plugin: MPlugin) {
return {
getBaseStaticRoute: () => `/plugins/${plugin.name}/${plugin.version}/static/`
}
}

View File

@ -109,7 +109,7 @@ export class RegisterHelpers {
const unregisterIdAndPassAuth = this.buildUnregisterIdAndPassAuth() const unregisterIdAndPassAuth = this.buildUnregisterIdAndPassAuth()
const unregisterExternalAuth = this.buildUnregisterExternalAuth() const unregisterExternalAuth = this.buildUnregisterExternalAuth()
const peertubeHelpers = buildPluginHelpers(this.npmName) const peertubeHelpers = buildPluginHelpers(this.plugin, this.npmName)
return { return {
registerHook, registerHook,

View File

@ -69,7 +69,20 @@ async function register ({
res.sendStatus(500) res.sendStatus(500)
} }
}) })
router.get('/server-config', async (req, res) => {
const serverConfig = await peertubeHelpers.config.getServerConfig()
return res.json({ serverConfig })
})
router.get('/static-route', async (req, res) => {
const staticRoute = await peertubeHelpers.plugin.getBaseStaticRoute()
return res.json({ staticRoute })
})
} }
} }
async function unregister () { async function unregister () {

View File

@ -12,7 +12,8 @@ import {
uploadVideoAndGetId, uploadVideoAndGetId,
viewVideo, viewVideo,
getVideosList, getVideosList,
waitJobs waitJobs,
makeGetRequest
} from '../../../shared/extra-utils' } from '../../../shared/extra-utils'
import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers'
import { expect } from 'chai' import { expect } from 'chai'
@ -68,6 +69,17 @@ describe('Test plugin helpers', function () {
it('Should have the correct webserver url', async function () { it('Should have the correct webserver url', async function () {
await waitUntilLog(servers[0], `server url is http://localhost:${servers[0].port}`) await waitUntilLog(servers[0], `server url is http://localhost:${servers[0].port}`)
}) })
it('Should have the correct config', async function () {
const res = await makeGetRequest({
url: servers[0].url,
path: '/plugins/test-four/router/server-config',
statusCodeExpected: HttpStatusCode.OK_200
})
expect(res.body.serverConfig).to.exist
expect(res.body.serverConfig.instance.name).to.equal('PeerTube')
})
}) })
describe('Server', function () { describe('Server', function () {
@ -77,6 +89,19 @@ describe('Test plugin helpers', function () {
}) })
}) })
describe('Plugin', function () {
it('Should get the base static route', async function () {
const res = await makeGetRequest({
url: servers[0].url,
path: '/plugins/test-four/router/static-route',
statusCodeExpected: HttpStatusCode.OK_200
})
expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/')
})
})
describe('Moderation', function () { describe('Moderation', function () {
let videoUUIDServer1: string let videoUUIDServer1: string

View File

@ -12,6 +12,7 @@ import {
PluginVideoPrivacyManager, PluginVideoPrivacyManager,
RegisterServerHookOptions, RegisterServerHookOptions,
RegisterServerSettingOptions, RegisterServerSettingOptions,
ServerConfig,
VideoBlacklistCreate VideoBlacklistCreate
} from '@shared/models' } from '@shared/models'
import { MVideoThumbnail } from '../models' import { MVideoThumbnail } from '../models'
@ -37,6 +38,8 @@ export type PeerTubeHelpers = {
config: { config: {
getWebserverUrl: () => string getWebserverUrl: () => string
getServerConfig: () => Promise<ServerConfig>
} }
moderation: { moderation: {
@ -52,6 +55,10 @@ export type PeerTubeHelpers = {
server: { server: {
getServerActor: () => Promise<ActorModel> getServerActor: () => Promise<ActorModel>
} }
plugin: {
getBaseStaticRoute: () => string
}
} }
export type RegisterServerOptions = { export type RegisterServerOptions = {