X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fserver%2Fplugin.ts;h=fa5b4cc4b3c51d9b99316712d57801ec8ea1b4dd;hb=92e66e04f7f51d37b465cff442ce47f6d6d7cadd;hp=84f7a14e47b22451f42847ad027653195362996a;hpb=3318147300b4f998adf728eb0a5a14a4c1829c51;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts index 84f7a14e4..fa5b4cc4b 100644 --- a/server/models/server/plugin.ts +++ b/server/models/server/plugin.ts @@ -2,7 +2,7 @@ import { FindAndCountOptions, json, QueryTypes } from 'sequelize' import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' import { MPlugin, MPluginFormattable } from '@server/types/models' import { AttributesOnly } from '@shared/typescript-utils' -import { PeerTubePlugin, PluginType, RegisterServerSettingOptions } from '../../../shared/models' +import { PeerTubePlugin, PluginType, RegisterServerSettingOptions, SettingEntries, SettingValue } from '../../../shared/models' import { isPluginDescriptionValid, isPluginHomepage, @@ -148,7 +148,7 @@ export class PluginModel extends Model>> { return PluginModel.findOne(query) .then(p => { - const result: { [settingName: string ]: string | boolean } = {} + const result: SettingEntries = {} for (const name of settingNames) { if (!p || !p.settings || p.settings[name] === undefined) { @@ -166,7 +166,7 @@ export class PluginModel extends Model>> { }) } - static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: string) { + static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: SettingValue) { const query = { where: { name: pluginName, @@ -239,11 +239,10 @@ export class PluginModel extends Model>> { if (options.pluginType) query.where['type'] = options.pluginType - return PluginModel - .findAndCountAll(query) - .then(({ rows, count }) => { - return { total: count, data: rows } - }) + return Promise.all([ + PluginModel.count(query), + PluginModel.findAll(query) + ]).then(([ total, data ]) => ({ total, data })) } static listInstalled (): Promise { @@ -273,7 +272,7 @@ export class PluginModel extends Model>> { } getPublicSettings (registeredSettings: RegisterServerSettingOptions[]) { - const result: { [ name: string ]: string } = {} + const result: SettingEntries = {} const settings = this.settings || {} for (const r of registeredSettings) {