server: improve API validation for creating apps

Resolves a FIXME comment.
This commit is contained in:
Johann150 2022-11-05 10:43:34 +01:00
parent 6f65326b32
commit 489eea0c67
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -2,6 +2,7 @@ import { Apps } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { unique } from '@/prelude/array.js'; import { unique } from '@/prelude/array.js';
import { secureRndstr } from '@/misc/secure-rndstr.js'; import { secureRndstr } from '@/misc/secure-rndstr.js';
import { kinds } from '@/misc/api-permissions.js';
import define from '../../define.js'; import define from '../../define.js';
export const meta = { export const meta = {
@ -21,10 +22,14 @@ export const paramDef = {
properties: { properties: {
name: { type: 'string' }, name: { type: 'string' },
description: { type: 'string' }, description: { type: 'string' },
permission: { type: 'array', uniqueItems: true, items: { permission: {
type: 'string', type: 'array',
// FIXME: add enum of possible permissions uniqueItems: true,
} }, items: {
type: 'string',
enum: kinds,
},
},
callbackUrl: { type: 'string', nullable: true }, callbackUrl: { type: 'string', nullable: true },
}, },
required: ['name', 'description', 'permission'], required: ['name', 'description', 'permission'],