This commit is contained in:
tamaina
2023-05-29 16:01:04 +00:00
parent 9135d2757e
commit bc15dde742
5 changed files with 240 additions and 275 deletions

View File

@@ -1,3 +1,4 @@
import { JSONSchema7 } from 'schema-type';
import { IEndpointMeta } from './endpoints.types';
import { localUsernameSchema, passwordSchema } from './schemas/user';
@@ -1535,6 +1536,19 @@ export const endpoints = {
},
}],
},
'admin/meta': {
tags: ['meta'],
requireCredential: true,
requireAdmin: true,
defines: [{
req: undefined,
res: {
$ref: 'https://misskey-hub.net/api/schemas/InstanceMetaAdmin',
},
}],
}
} as const satisfies { [x: string]: IEndpointMeta; };
/**

View File

@@ -43,6 +43,10 @@ import {
packedRolePolicySchema,
packedRoleCondFormulaSchema,
} from './schemas/role.js';
import {
InstanceMetaSharedSchema,
InstanceMetaAdminSchema,
} from './schemas/instance-meta.js';
import { Error, ApiError } from './schemas/error.js';
import type { JSONSchema7, JSONSchema7Definition, GetDef, GetRefs, GetKeys, UnionToArray } from 'schema-type';
@@ -89,6 +93,8 @@ export const refs = {
RolePolicy: packedRolePolicySchema,
RoleCondFormula: packedRoleCondFormulaSchema,
AbuseUserReport: packedAbuseUserReportSchema,
InstanceMetaShared: InstanceMetaSharedSchema,
InstanceMetaAdmin: InstanceMetaAdminSchema,
Error: Error,
ApiError: ApiError,

View File

@@ -0,0 +1,209 @@
import type { JSONSchema7, JSONSchema7Definition } from 'schema-type';
export const InstanceMetaSharedSchema = {
$id: 'https://misskey-hub.net/api/schemas/InstanceMetaShared',
type: 'object',
properties: {
maintainerName: { type: ['string', 'null'] },
maintainerEmail: { type: ['string', 'null'] },
version: { type: 'string' },
name: { type: ['string', 'null'] },
uri: { type: 'string' },
description: { type: ['string', 'null'] },
langs: {
type: 'array',
items: { type: 'string' },
},
tosUrl: { type: ['string', 'null'] },
repositoryUrl: { type: 'string' },
feedbackUrl: { type: ['string', 'null'] },
disableRegistration: { type: 'boolean' },
emailRequiredForSignup: { type: 'boolean' },
enableHcaptcha: { type: 'boolean' },
hcaptchaSiteKey: { type: ['string', 'null'] },
enableRecaptcha: { type: 'boolean' },
recaptchaSiteKey: { type: ['string', 'null'] },
enableTurnstile: { type: 'boolean' },
turnstileSiteKey: { type: ['string', 'null'] },
swPublickey: { type: ['string', 'null'] },
themeColor: { type: ['string', 'null'] },
mascotImageUrl: {
type: ['string', 'null'],
default: '/assets/ai.png',
},
bannerUrl: { type: ['string', 'null'] },
errorImageUrl: {
type: ['string', 'null'],
default: 'https://xn--931a.moe/aiart/yubitun.png',
},
iconUrl: { type: ['string', 'null'] },
backgroundImageUrl: { type: ['string', 'null'] },
logoImageUrl: { type: ['string', 'null'] },
defaultLightTheme: { type: ['string', 'null'] },
defaultDarkTheme: { type: ['string', 'null'] },
enableEmail: { type: 'boolean' },
enableServiceWorker: { type: 'boolean' },
translatorAvailable: { type: 'boolean' },
policies: {
type: 'object',
},
},
required: [
'maintainerName',
'maintainerEmail',
'version',
'name',
'uri',
'description',
'langs',
'tosUrl',
'repositoryUrl',
'feedbackUrl',
'disableRegistration',
'emailRequiredForSignup',
'enableHcaptcha',
'hcaptchaSiteKey',
'enableRecaptcha',
'recaptchaSiteKey',
'enableTurnstile',
'turnstileSiteKey',
'swPublickey',
'themeColor',
'mascotImageUrl',
'bannerUrl',
'errorImageUrl',
'iconUrl',
'backgroundImageUrl',
'logoImageUrl',
'defaultLightTheme',
'defaultDarkTheme',
'enableEmail',
'enableServiceWorker',
'translatorAvailable',
'policies',
],
} as const satisfies JSONSchema7Definition;
export const InstanceMetaAdminSchema = {
$id: 'https://misskey-hub.net/api/schemas/InstanceMetaAdmin',
allOf: [
{ $ref: 'https://misskey-hub.net/api/schemas/InstanceMetaShared' },
{
type: 'object',
properties: {
cacheRemoteFiles: { type: 'boolean' },
pinnedUsers: {
type: 'array',
items: {
type: 'string',
},
},
hiddenTags: {
type: 'array',
items: {
type: 'string',
},
},
blockedHosts: {
type: 'array',
items: {
type: 'string',
},
},
sensitiveWords: {
type: 'array',
items: {
type: 'string',
},
},
preservedUsernames: {
type: 'array',
items: {
type: 'string',
},
},
hcaptchaSecretKey: { type: ['string', 'null'] },
recaptchaSecretKey: { type: ['string', 'null'] },
turnstileSecretKey: { type: ['string', 'null'] },
sensitiveMediaDetection: { type: 'string', enum: ['none', 'all', 'local', 'remote'] },
sensitiveMediaDetectionSensitivity: { type: 'string', enum: ['medium', 'low', 'high', 'veryLow', 'veryHigh'] },
setSensitiveFlagAutomatically: { type: 'boolean' },
enableSensitiveMediaDetectionForVideos: { type: 'boolean' },
proxyAccountId: {
$ref: 'https://misskey-hub.net/api/schemas/Id',
},
summaryProxy: { type: ['string', 'null'] },
email: { type: ['string', 'null'] },
smtpSecure: { type: 'boolean' },
smtpHost: { type: ['string', 'null'] },
smtpPort: { type: ['number', 'null'] },
smtpUser: { type: ['string', 'null'] },
smtpPass: { type: ['string', 'null'] },
swPrivateKey: { type: ['string', 'null'] },
useObjectStorage: { type: 'boolean' },
objectStorageBaseUrl: { type: ['string', 'null'] },
objectStorageBucket: { type: ['string', 'null'] },
objectStoragePrefix: { type: ['string', 'null'] },
objectStorageEndpoint: { type: ['string', 'null'] },
objectStorageRegion: { type: ['string', 'null'] },
objectStoragePort: { type: ['number', 'null'] },
objectStorageAccessKey: { type: ['string', 'null'] },
objectStorageSecretKey: { type: ['string', 'null'] },
objectStorageUseSSL: { type: 'boolean' },
objectStorageUseProxy: { type: 'boolean' },
objectStorageSetPublicRead: { type: 'boolean' },
objectStorageS3ForcePathStyle: { type: 'boolean' },
deeplAuthKey: { type: ['string', 'null'] },
deeplIsPro: { type: 'boolean' },
enableIpLogging: { type: 'boolean' },
enableActiveEmailValidation: { type: 'boolean' },
enableChartsForRemoteUser: { type: 'boolean' },
enableChartsForFederatedInstances: { type: 'boolean' },
} satisfies Record<string, JSONSchema7>,
required: [
'cacheRemoteFiles',
'pinnedUsers',
'hiddenTags',
'blockedHosts',
'sensitiveWords',
'preservedUsernames',
'hcaptchaSecretKey',
'recaptchaSecretKey',
'turnstileSecretKey',
'sensitiveMediaDetection',
'sensitiveMediaDetectionSensitivity',
'setSensitiveFlagAutomatically',
'enableSensitiveMediaDetectionForVideos',
'proxyAccountId',
'summalyProxy',
'email',
'smtpSecure',
'smtpHost',
'smtpPort',
'smtpUser',
'smtpPass',
'swPrivateKey',
'useObjectStorage',
'objectStorageBaseUrl',
'objectStorageBucket',
'objectStoragePrefix',
'objectStorageEndpoint',
'objectStorageRegion',
'objectStoragePort',
'objectStorageAccessKey',
'objectStorageSecretKey',
'objectStorageUseSSL',
'objectStorageUseProxy',
'objectStorageSetPublicRead',
'objectStorageS3ForcePathStyle',
'deeplAuthKey',
'deeplIsPro',
'enableIpLogging',
'enableActiveEmailValidation',
'enableChartsForRemoteUser',
'enableChartsForFederatedInstances',
],
},
]
} as const satisfies JSONSchema7Definition;