summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/meta.ts
blob: 3d26003a1a746ecb039ea0a9a78746380f7591e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import $ from 'cafy';
import * as os from 'os';
import config from '../../../config';
import Meta from '../../../models/meta';
import Emoji from '../../../models/emoji';
import define from '../define';

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 met: any = (await Meta.findOne()) || {};

	const emojis = await Emoji.find({ host: null }, {
		fields: {
			_id: false
		}
	});

	res({
		maintainer: config.maintainer,

		version: pkg.version,
		clientVersion: client.version,

		name: config.name || 'Misskey',
		description: config.description,

		secure: config.https != null,
		machine: os.hostname(),
		os: os.platform(),
		node: process.version,

		cpu: {
			model: os.cpus()[0].model,
			cores: os.cpus().length
		},

		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) ? met.hidedTags : undefined,
		bannerUrl: met.bannerUrl,
		maxNoteTextLength: config.maxNoteTextLength,

		emojis: emojis,

		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
	});
}));