From 9022ab9f2a5872c02f6d20f1d96ebc1bee6dd43f Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 10 Oct 2022 17:36:13 +0200 Subject: [PATCH] backend: ignore detail parameter on meta endpoint Also allow meta endpoint to be fetched via GET. Changelog: Removed --- .../backend/src/server/api/endpoints/meta.ts | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 0d11c5a92..cbf74ef04 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -10,6 +10,9 @@ export const meta = { requireCredential: false, + allowGet: true, + cacheSec: 60, + res: { type: 'object', optional: false, nullable: false, @@ -253,7 +256,12 @@ export const meta = { export const paramDef = { type: 'object', properties: { - detail: { type: 'boolean', default: true }, + detail: { + deprecated: true, + description: 'This parameter is ignored. You will always get all details (as if it was `true`).', + type: 'boolean', + default: true, + }, }, required: [], } as const; @@ -276,7 +284,7 @@ export default define(meta, paramDef, async (ps, me) => { }, }); - const response: any = { + return { maintainerName: instance.maintainerName, maintainerEmail: instance.maintainerEmail, @@ -317,21 +325,16 @@ export default define(meta, paramDef, async (ps, me) => { translatorAvailable: instance.deeplAuthKey != null, - ...(ps.detail ? { - pinnedPages: instance.pinnedPages, - pinnedClipId: instance.pinnedClipId, - cacheRemoteFiles: instance.cacheRemoteFiles, - requireSetup: (await Users.countBy({ - host: IsNull(), - })) === 0, - } : {}), - }; + pinnedPages: instance.pinnedPages, + pinnedClipId: instance.pinnedClipId, + cacheRemoteFiles: instance.cacheRemoteFiles, + requireSetup: (await Users.countBy({ + host: IsNull(), + })) === 0, - if (ps.detail) { - const proxyAccount = instance.proxyAccountId ? await Users.pack(instance.proxyAccountId).catch(() => null) : null; + proxyAccountName: instance.proxyAccountId ? (await Users.pack(instance.proxyAccountId).catch(() => null))?.username : null, - response.proxyAccountName = proxyAccount ? proxyAccount.username : null; - response.features = { + features: { registration: !instance.disableRegistration, localTimeLine: !instance.disableLocalTimeline, globalTimeLine: !instance.disableGlobalTimeline, @@ -345,8 +348,6 @@ export default define(meta, paramDef, async (ps, me) => { discord: instance.enableDiscordIntegration, serviceWorker: instance.enableServiceWorker, miauth: true, - }; - } - - return response; + }, + }; });