Remove backward compatibility (peertubeHelpers.plugin always available).

This commit is contained in:
John Livingston
2021-06-02 15:48:56 +02:00
parent 22f392d838
commit 10bbb7f040
3 changed files with 9 additions and 14 deletions

View File

@ -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> {