From befc35a3acc3ff71af5f58fc95ce6ec3897b4144 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 2 Nov 2018 12:16:03 +0900 Subject: [PATCH] Update src/server/api/endpoints/meta.ts --- src/server/api/endpoints/meta.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 87b6774b2..e33023b07 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -1,8 +1,10 @@ +import $ from 'cafy'; import * as os from 'os'; import config from '../../../config'; import Meta from '../../../models/meta'; import { ILocalUser } from '../../../models/user'; import Emoji from '../../../models/emoji'; +import getParams from '../get-params'; const pkg = require('../../../../package.json'); const client = require('../../../../built/client/meta.json'); @@ -17,11 +19,19 @@ export const meta = { requireCredential: false, - params: {}, + params: { + detail: { + validator: $.bool.optional, + default: true + } + }, }; export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { - const meta: any = (await Meta.findOne()) || {}; + const [ps, psErr] = getParams(meta, params); + if (psErr) return rej(psErr); + + const met: any = (await Meta.findOne()) || {}; const emojis = await Emoji.find({ host: null }); @@ -44,26 +54,26 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => cores: os.cpus().length }, - broadcasts: meta.broadcasts || [], - disableRegistration: meta.disableRegistration, - disableLocalTimeline: meta.disableLocalTimeline, + broadcasts: met.broadcasts || [], + disableRegistration: met.disableRegistration, + disableLocalTimeline: met.disableLocalTimeline, driveCapacityPerLocalUserMb: config.localDriveCapacityMb, recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null, swPublickey: config.sw ? config.sw.public_key : null, - hidedTags: (me && me.isAdmin) ? meta.hidedTags : undefined, - bannerUrl: meta.bannerUrl, + hidedTags: (me && me.isAdmin) ? met.hidedTags : undefined, + bannerUrl: met.bannerUrl, maxNoteTextLength: config.maxNoteTextLength, emojis: emojis, - features: { - registration: !meta.disableRegistration, - localTimeLine: !meta.disableLocalTimeline, + features: ps.detail ? { + registration: !met.disableRegistration, + localTimeLine: !met.disableLocalTimeline, elasticsearch: config.elasticsearch ? true : false, recaptcha: config.recaptcha ? true : false, objectStorage: config.drive && config.drive.storage === 'minio', twitter: config.twitter ? true : false, serviceWorker: config.sw ? true : false, userRecommendation: config.user_recommendation ? config.user_recommendation : {} - } + } : undefined }); });