summaryrefslogtreecommitdiff
path: root/src/models/meta.ts
blob: 3eb73681ac3fc86e323fc78b15d23e1a8b75be3f (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import db from '../db/mongodb';
import config from '../config';

const Meta = db.get<IMeta>('meta');
export default Meta;

// 後方互換性のため。
// 過去のMisskeyではインスタンス名や紹介を設定ファイルに記述していたのでそれを移行
if ((config as any).name) {
	Meta.findOne({}).then(m => {
		if (m != null && m.name == null) {
			Meta.update({}, {
				$set: {
					name: (config as any).name
				}
			});
		}
	});
}
if ((config as any).description) {
	Meta.findOne({}).then(m => {
		if (m != null && m.description == null) {
			Meta.update({}, {
				$set: {
					description: (config as any).description
				}
			});
		}
	});
}
if ((config as any).localDriveCapacityMb) {
	Meta.findOne({}).then(m => {
		if (m != null && m.localDriveCapacityMb == null) {
			Meta.update({}, {
				$set: {
					localDriveCapacityMb: (config as any).localDriveCapacityMb
				}
			});
		}
	});
}
if ((config as any).remoteDriveCapacityMb) {
	Meta.findOne({}).then(m => {
		if (m != null && m.remoteDriveCapacityMb == null) {
			Meta.update({}, {
				$set: {
					remoteDriveCapacityMb: (config as any).remoteDriveCapacityMb
				}
			});
		}
	});
}
if ((config as any).preventCacheRemoteFiles) {
	Meta.findOne({}).then(m => {
		if (m != null && m.cacheRemoteFiles == null) {
			Meta.update({}, {
				$set: {
					cacheRemoteFiles: !(config as any).preventCacheRemoteFiles
				}
			});
		}
	});
}
if ((config as any).recaptcha) {
	Meta.findOne({}).then(m => {
		if (m != null && m.enableRecaptcha == null) {
			Meta.update({}, {
				$set: {
					enableRecaptcha: (config as any).recaptcha != null,
					recaptchaSiteKey: (config as any).recaptcha.site_key,
					recaptchaSecretKey: (config as any).recaptcha.secret_key,
				}
			});
		}
	});
}

export type IMeta = {
	name?: string;
	description?: string;
	broadcasts?: any[];
	stats?: {
		notesCount: number;
		originalNotesCount: number;
		usersCount: number;
		originalUsersCount: number;
	};
	disableRegistration?: boolean;
	disableLocalTimeline?: boolean;
	hidedTags?: string[];
	bannerUrl?: string;

	cacheRemoteFiles?: boolean;

	enableRecaptcha?: boolean;
	recaptchaSiteKey?: string;
	recaptchaSecretKey?: string;

	/**
	 * Drive capacity of a local user (MB)
	 */
	localDriveCapacityMb?: number;

	/**
	 * Drive capacity of a remote user (MB)
	 */
	remoteDriveCapacityMb?: number;

	/**
	 * Max allowed note text length in charactors
	 */
	maxNoteTextLength?: number;
};