Update src/server/api/endpoints/meta.ts

This commit is contained in:
syuilo 2018-11-02 12:16:03 +09:00
parent 2e9bbf389e
commit befc35a3ac
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -1,8 +1,10 @@
import $ from 'cafy';
import * as os from 'os'; import * as os from 'os';
import config from '../../../config'; import config from '../../../config';
import Meta from '../../../models/meta'; import Meta from '../../../models/meta';
import { ILocalUser } from '../../../models/user'; import { ILocalUser } from '../../../models/user';
import Emoji from '../../../models/emoji'; import Emoji from '../../../models/emoji';
import getParams from '../get-params';
const pkg = require('../../../../package.json'); const pkg = require('../../../../package.json');
const client = require('../../../../built/client/meta.json'); const client = require('../../../../built/client/meta.json');
@ -17,11 +19,19 @@ export const meta = {
requireCredential: false, requireCredential: false,
params: {}, params: {
detail: {
validator: $.bool.optional,
default: true
}
},
}; };
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { 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 }); 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 cores: os.cpus().length
}, },
broadcasts: meta.broadcasts || [], broadcasts: met.broadcasts || [],
disableRegistration: meta.disableRegistration, disableRegistration: met.disableRegistration,
disableLocalTimeline: meta.disableLocalTimeline, disableLocalTimeline: met.disableLocalTimeline,
driveCapacityPerLocalUserMb: config.localDriveCapacityMb, driveCapacityPerLocalUserMb: config.localDriveCapacityMb,
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null, recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
swPublickey: config.sw ? config.sw.public_key : null, swPublickey: config.sw ? config.sw.public_key : null,
hidedTags: (me && me.isAdmin) ? meta.hidedTags : undefined, hidedTags: (me && me.isAdmin) ? met.hidedTags : undefined,
bannerUrl: meta.bannerUrl, bannerUrl: met.bannerUrl,
maxNoteTextLength: config.maxNoteTextLength, maxNoteTextLength: config.maxNoteTextLength,
emojis: emojis, emojis: emojis,
features: { features: ps.detail ? {
registration: !meta.disableRegistration, registration: !met.disableRegistration,
localTimeLine: !meta.disableLocalTimeline, localTimeLine: !met.disableLocalTimeline,
elasticsearch: config.elasticsearch ? true : false, elasticsearch: config.elasticsearch ? true : false,
recaptcha: config.recaptcha ? true : false, recaptcha: config.recaptcha ? true : false,
objectStorage: config.drive && config.drive.storage === 'minio', objectStorage: config.drive && config.drive.storage === 'minio',
twitter: config.twitter ? true : false, twitter: config.twitter ? true : false,
serviceWorker: config.sw ? true : false, serviceWorker: config.sw ? true : false,
userRecommendation: config.user_recommendation ? config.user_recommendation : {} userRecommendation: config.user_recommendation ? config.user_recommendation : {}
} } : undefined
}); });
}); });