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: {
|
||||
getAuthUser: (res: express.Response) => Promise<MUserDefault | undefined>
|
||||
}
|
||||
// Added in Peertube 3.2.0
|
||||
plugin?: {
|
||||
plugin: {
|
||||
getBaseStaticRoute: () => string
|
||||
getBaseRouterRoute: () => string
|
||||
getDataDirectoryPath: () => string
|
||||
|
@ -12,21 +12,17 @@ if (!/^peertube-plugin-[-a-z]+$/.test(pluginName)) {
|
||||
const pluginShortName = pluginName.substring('peertube-plugin-'.length)
|
||||
|
||||
function getBaseRouterRoute (options: RegisterServerOptions): string {
|
||||
// In Peertube <= 3.1.0, PeertubeHelpers dont provide this function
|
||||
// Available in Peertube >= 3.2.0
|
||||
if (options.peertubeHelpers.plugin) {
|
||||
return options.peertubeHelpers.plugin.getBaseRouterRoute()
|
||||
if (!options.peertubeHelpers.plugin) {
|
||||
throw new Error('Missing peertubeHelpers.plugin, have you the correct Peertube version?')
|
||||
}
|
||||
return '/plugins/' + pluginShortName + '/' + version + '/router/'
|
||||
return options.peertubeHelpers.plugin.getBaseRouterRoute()
|
||||
}
|
||||
|
||||
function getBaseStaticRoute (options: RegisterServerOptions): string {
|
||||
// In Peertube <= 3.1.0, PeertubeHelpers dont provide this function.
|
||||
// Available in Peertube >= 3.2.0
|
||||
if (options.peertubeHelpers.plugin) {
|
||||
return options.peertubeHelpers.plugin.getBaseStaticRoute()
|
||||
if (!options.peertubeHelpers.plugin) {
|
||||
throw new Error('Missing peertubeHelpers.plugin, have you the correct Peertube version?')
|
||||
}
|
||||
return '/plugins/' + pluginShortName + '/' + version + '/static/'
|
||||
return options.peertubeHelpers.plugin.getBaseStaticRoute()
|
||||
}
|
||||
|
||||
async function isUserAdmin (options: RegisterServerOptions, res: Response): Promise<boolean> {
|
||||
|
@ -12,8 +12,8 @@ async function getWorkingDir (options: RegisterServerOptions): Promise<string> {
|
||||
const logger = peertubeHelpers.logger
|
||||
logger.debug('Calling getWorkingDir')
|
||||
|
||||
if (!peertubeHelpers.plugin?.getDataDirectoryPath) {
|
||||
throw new Error('Cant get the plugin Data Directory')
|
||||
if (!peertubeHelpers.plugin) {
|
||||
throw new Error('Missing peertubeHelpers.plugin, have you the correct Peertube version?')
|
||||
}
|
||||
const dir = path.resolve(peertubeHelpers.plugin.getDataDirectoryPath(), 'prosody')
|
||||
logger.debug('getWorkingDir will return the dir ' + dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user