mirror of https://github.com/Chocobozzz/PeerTube
Add peertube plugin index website models
parent
30ff39e7f0
commit
503c6f440a
|
@ -4,7 +4,6 @@ import { PluginType } from '../../../shared/models/plugins/plugin.type'
|
|||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
import { PluginPackageJson } from '../../../shared/models/plugins/plugin-package-json.model'
|
||||
import { isUrlValid } from './activitypub/misc'
|
||||
import { isThemeRegistered } from '../../lib/plugins/theme-utils'
|
||||
|
||||
const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS
|
||||
|
||||
|
@ -66,8 +65,8 @@ function isCSSPathsValid (css: any[]) {
|
|||
return isArray(css) && css.every(c => isSafePath(c))
|
||||
}
|
||||
|
||||
function isThemeValid (name: string) {
|
||||
return isPluginNameValid(name) && isThemeRegistered(name)
|
||||
function isThemeNameValid (name: string) {
|
||||
return isPluginNameValid(name)
|
||||
}
|
||||
|
||||
function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) {
|
||||
|
@ -91,7 +90,7 @@ function isLibraryCodeValid (library: any) {
|
|||
export {
|
||||
isPluginTypeValid,
|
||||
isPackageJSONValid,
|
||||
isThemeValid,
|
||||
isThemeNameValid,
|
||||
isPluginHomepage,
|
||||
isPluginVersionValid,
|
||||
isPluginNameValid,
|
||||
|
|
|
@ -171,7 +171,7 @@ const SCHEDULER_INTERVALS_MS = {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
let CONSTRAINTS_FIELDS = {
|
||||
const CONSTRAINTS_FIELDS = {
|
||||
USERS: {
|
||||
NAME: { min: 1, max: 120 }, // Length
|
||||
DESCRIPTION: { min: 3, max: 1000 }, // Length
|
||||
|
|
|
@ -5,7 +5,8 @@ import { logger } from '../../helpers/logger'
|
|||
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
|
||||
import { Emailer } from '../../lib/emailer'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isThemeValid } from '../../helpers/custom-validators/plugins'
|
||||
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
|
||||
import { isThemeRegistered } from '../../lib/plugins/theme-utils'
|
||||
|
||||
const customConfigUpdateValidator = [
|
||||
body('instance.name').exists().withMessage('Should have a valid instance name'),
|
||||
|
@ -48,7 +49,7 @@ const customConfigUpdateValidator = [
|
|||
body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'),
|
||||
body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'),
|
||||
|
||||
body('theme.default').custom(isThemeValid).withMessage('Should have a valid theme'),
|
||||
body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })
|
||||
|
|
|
@ -28,7 +28,8 @@ import { ActorModel } from '../../models/activitypub/actor'
|
|||
import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
|
||||
import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels'
|
||||
import { UserRegister } from '../../../shared/models/users/user-register.model'
|
||||
import { isThemeValid } from '../../helpers/custom-validators/plugins'
|
||||
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
|
||||
import { isThemeRegistered } from '../../lib/plugins/theme-utils'
|
||||
|
||||
const usersAddValidator = [
|
||||
body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
|
||||
|
@ -207,7 +208,7 @@ const usersUpdateMeValidator = [
|
|||
.custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'),
|
||||
body('theme')
|
||||
.optional()
|
||||
.custom(isThemeValid).withMessage('Should have a valid theme'),
|
||||
.custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') })
|
||||
|
|
|
@ -52,7 +52,7 @@ import { ActorModel } from '../activitypub/actor'
|
|||
import { ActorFollowModel } from '../activitypub/actor-follow'
|
||||
import { VideoImportModel } from '../video/video-import'
|
||||
import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'
|
||||
import { isThemeValid } from '../../helpers/custom-validators/plugins'
|
||||
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
|
||||
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
|
||||
|
||||
enum ScopeNames {
|
||||
|
@ -191,7 +191,7 @@ export class UserModel extends Model<UserModel> {
|
|||
|
||||
@AllowNull(false)
|
||||
@Default(DEFAULT_THEME_NAME)
|
||||
@Is('UserTheme', value => throwIfNotValid(value, isThemeValid, 'theme'))
|
||||
@Is('UserTheme', value => throwIfNotValid(value, isThemeNameValid, 'theme'))
|
||||
@Column
|
||||
theme: string
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export interface PeerTubePluginIndex {
|
||||
npmName: string
|
||||
description: string
|
||||
homepage: string
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
|
||||
popularity: number
|
||||
|
||||
latestVersion: string
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
export interface PeertubePluginLatestVersion {
|
||||
currentPeerTubeEngine?: string,
|
||||
|
||||
npmNames: string[]
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import { PluginType } from './plugin.type'
|
||||
|
||||
export interface PeertubePluginList {
|
||||
start: number
|
||||
count: number
|
||||
sort: string
|
||||
pluginType?: PluginType
|
||||
currentPeerTubeEngine?: string
|
||||
search?: string
|
||||
}
|
Loading…
Reference in New Issue