trashposs/src/server/api/endpoints/meta.ts
Hakaba Hitoyo 82ab386b83 Feature / user recommendation config in admin ui (#3357)
* add config for external user recommendation into admin ui

* debug

* correct admin ui

* switch external user recommendation to admin ui config

* debug

* debug

* debug

* Revert "debug"

This reverts commit f4a0460e5bde21cd1f39a735f496a2d74233ef3f.

* explicit parseInt radix

* add Japanese message

* change default engine to https

* remove unused settings

* debug

* nullable externalUserRecommendationTimeout
2018-11-21 23:44:59 +09:00

114 lines
3.4 KiB
TypeScript

import $ from 'cafy';
import * as os from 'os';
import config from '../../../config';
import Emoji from '../../../models/emoji';
import define from '../define';
import fetchMeta from '../../../misc/fetch-meta';
const pkg = require('../../../../package.json');
const client = require('../../../../built/client/meta.json');
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'インスタンス情報を取得します。',
'en-US': 'Get the information of this instance.'
},
requireCredential: false,
params: {
detail: {
validator: $.bool.optional,
default: true
}
},
};
export default define(meta, (ps, me) => new Promise(async (res, rej) => {
const instance = await fetchMeta();
const emojis = await Emoji.find({ host: null }, {
fields: {
_id: false
}
});
const response: any = {
maintainer: instance.maintainer,
version: pkg.version,
clientVersion: client.version,
name: instance.name,
description: instance.description,
langs: instance.langs,
secure: config.https != null,
machine: os.hostname(),
os: os.platform(),
node: process.version,
cpu: {
model: os.cpus()[0].model,
cores: os.cpus().length
},
broadcasts: instance.broadcasts || [],
disableRegistration: instance.disableRegistration,
disableLocalTimeline: instance.disableLocalTimeline,
driveCapacityPerLocalUserMb: instance.localDriveCapacityMb,
driveCapacityPerRemoteUserMb: instance.remoteDriveCapacityMb,
cacheRemoteFiles: instance.cacheRemoteFiles,
enableRecaptcha: instance.enableRecaptcha,
recaptchaSiteKey: instance.recaptchaSiteKey,
swPublickey: config.sw ? config.sw.public_key : null,
bannerUrl: instance.bannerUrl,
maxNoteTextLength: instance.maxNoteTextLength,
emojis: emojis,
enableTwitterIntegration: instance.enableTwitterIntegration,
enableGithubIntegration: instance.enableGithubIntegration,
enableDiscordIntegration: instance.enableDiscordIntegration,
enableExternalUserRecommendation: instance.enableExternalUserRecommendation,
externalUserRecommendationEngine: instance.externalUserRecommendationEngine,
externalUserRecommendationTimeout: instance.externalUserRecommendationTimeout
};
if (ps.detail) {
response.features = {
registration: !instance.disableRegistration,
localTimeLine: !instance.disableLocalTimeline,
elasticsearch: config.elasticsearch ? true : false,
recaptcha: instance.enableRecaptcha,
objectStorage: config.drive && config.drive.storage === 'minio',
twitter: instance.enableTwitterIntegration,
github: instance.enableGithubIntegration,
discord: instance.enableDiscordIntegration,
serviceWorker: config.sw ? true : false,
userRecommendation: {
external: instance.enableExternalUserRecommendation,
engine: instance.externalUserRecommendationEngine,
timeout: instance.externalUserRecommendationTimeout
}
};
}
if (me && (me.isAdmin || me.isModerator)) {
response.hidedTags = instance.hidedTags;
response.recaptchaSecretKey = instance.recaptchaSecretKey;
response.proxyAccount = instance.proxyAccount;
response.twitterConsumerKey = instance.twitterConsumerKey;
response.twitterConsumerSecret = instance.twitterConsumerSecret;
response.githubClientId = instance.githubClientId;
response.githubClientSecret = instance.githubClientSecret;
response.discordClientId = instance.discordClientId;
response.discordClientSecret = instance.discordClientSecret;
}
res(response);
}));