From 6702a1b2ccd666285dee9c72b5bace641d2fce8b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 Jul 2019 11:33:22 +0200 Subject: Add ability to search available plugins --- server/models/server/plugin.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'server/models') diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts index bd3d7a81e..ba43713f6 100644 --- a/server/models/server/plugin.ts +++ b/server/models/server/plugin.ts @@ -10,6 +10,7 @@ import { import { PluginType } from '../../../shared/models/plugins/plugin.type' import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model' import { FindAndCountOptions, json } from 'sequelize' +import { PeerTubePluginIndex } from '../../../shared/models/plugins/peertube-plugin-index.model' @DefaultScope(() => ({ attributes: { @@ -177,7 +178,7 @@ export class PluginModel extends Model { } static listForApi (options: { - type?: PluginType, + pluginType?: PluginType, uninstalled?: boolean, start: number, count: number, @@ -193,7 +194,7 @@ export class PluginModel extends Model { } } - if (options.type) query.where['type'] = options.type + if (options.pluginType) query.where['type'] = options.pluginType return PluginModel .findAndCountAll(query) @@ -202,8 +203,18 @@ export class PluginModel extends Model { }) } - static normalizePluginName (name: string) { - return name.replace(/^peertube-((theme)|(plugin))-/, '') + static listInstalled () { + const query = { + where: { + uninstalled: false + } + } + + return PluginModel.findAll(query) + } + + static normalizePluginName (npmName: string) { + return npmName.replace(/^peertube-((theme)|(plugin))-/, '') } static getTypeFromNpmName (npmName: string) { -- cgit v1.2.3