Remove backward compatibility (peertubeHelpers.plugin always available).
This commit is contained in:
parent
22f392d838
commit
10bbb7f040
3
server/@types/peertube.d.ts
vendored
3
server/@types/peertube.d.ts
vendored
@ -150,8 +150,7 @@ interface PeerTubeHelpers {
|
|||||||
user: {
|
user: {
|
||||||
getAuthUser: (res: express.Response) => Promise<MUserDefault | undefined>
|
getAuthUser: (res: express.Response) => Promise<MUserDefault | undefined>
|
||||||
}
|
}
|
||||||
// Added in Peertube 3.2.0
|
plugin: {
|
||||||
plugin?: {
|
|
||||||
getBaseStaticRoute: () => string
|
getBaseStaticRoute: () => string
|
||||||
getBaseRouterRoute: () => string
|
getBaseRouterRoute: () => string
|
||||||
getDataDirectoryPath: () => string
|
getDataDirectoryPath: () => string
|
||||||
|
@ -12,21 +12,17 @@ if (!/^peertube-plugin-[-a-z]+$/.test(pluginName)) {
|
|||||||
const pluginShortName = pluginName.substring('peertube-plugin-'.length)
|
const pluginShortName = pluginName.substring('peertube-plugin-'.length)
|
||||||
|
|
||||||
function getBaseRouterRoute (options: RegisterServerOptions): string {
|
function getBaseRouterRoute (options: RegisterServerOptions): string {
|
||||||
// In Peertube <= 3.1.0, PeertubeHelpers dont provide this function
|
if (!options.peertubeHelpers.plugin) {
|
||||||
// Available in Peertube >= 3.2.0
|
throw new Error('Missing peertubeHelpers.plugin, have you the correct Peertube version?')
|
||||||
if (options.peertubeHelpers.plugin) {
|
|
||||||
return options.peertubeHelpers.plugin.getBaseRouterRoute()
|
|
||||||
}
|
}
|
||||||
return '/plugins/' + pluginShortName + '/' + version + '/router/'
|
return options.peertubeHelpers.plugin.getBaseRouterRoute()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBaseStaticRoute (options: RegisterServerOptions): string {
|
function getBaseStaticRoute (options: RegisterServerOptions): string {
|
||||||
// In Peertube <= 3.1.0, PeertubeHelpers dont provide this function.
|
if (!options.peertubeHelpers.plugin) {
|
||||||
// Available in Peertube >= 3.2.0
|
throw new Error('Missing peertubeHelpers.plugin, have you the correct Peertube version?')
|
||||||
if (options.peertubeHelpers.plugin) {
|
|
||||||
return options.peertubeHelpers.plugin.getBaseStaticRoute()
|
|
||||||
}
|
}
|
||||||
return '/plugins/' + pluginShortName + '/' + version + '/static/'
|
return options.peertubeHelpers.plugin.getBaseStaticRoute()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isUserAdmin (options: RegisterServerOptions, res: Response): Promise<boolean> {
|
async function isUserAdmin (options: RegisterServerOptions, res: Response): Promise<boolean> {
|
||||||
|
@ -12,8 +12,8 @@ async function getWorkingDir (options: RegisterServerOptions): Promise<string> {
|
|||||||
const logger = peertubeHelpers.logger
|
const logger = peertubeHelpers.logger
|
||||||
logger.debug('Calling getWorkingDir')
|
logger.debug('Calling getWorkingDir')
|
||||||
|
|
||||||
if (!peertubeHelpers.plugin?.getDataDirectoryPath) {
|
if (!peertubeHelpers.plugin) {
|
||||||
throw new Error('Cant get the plugin Data Directory')
|
throw new Error('Missing peertubeHelpers.plugin, have you the correct Peertube version?')
|
||||||
}
|
}
|
||||||
const dir = path.resolve(peertubeHelpers.plugin.getDataDirectoryPath(), 'prosody')
|
const dir = path.resolve(peertubeHelpers.plugin.getDataDirectoryPath(), 'prosody')
|
||||||
logger.debug('getWorkingDir will return the dir ' + dir)
|
logger.debug('getWorkingDir will return the dir ' + dir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user