summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/Instance.ts
blob: 0cde4b75fc823de930aee89459eebe343c056f75 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { Entity, PrimaryColumn, Index, Column } from 'typeorm';
import { id } from './util/id.js';

@Index('IDX_instance_host_key', { synchronize: false }) // ((lower(reverse("host"::text)) || '.'::text)
@Entity('instance')
export class MiInstance {
	@PrimaryColumn(id())
	public id: string;

	/**
	 * このインスタンスを捕捉した日時
	 */
	@Index()
	@Column('timestamp with time zone', {
		comment: 'The caught date of the Instance.',
	})
	public firstRetrievedAt: Date;

	/**
	 * ホスト
	 */
	@Index({ unique: true })
	@Column('varchar', {
		length: 128,
		comment: 'The host of the Instance.',
	})
	public host: string;

	/**
	 * インスタンスのユーザー数
	 */
	@Column('integer', {
		default: 0,
		comment: 'The count of the users of the Instance.',
	})
	public usersCount: number;

	/**
	 * インスタンスの投稿数
	 */
	@Column('integer', {
		default: 0,
		comment: 'The count of the notes of the Instance.',
	})
	public notesCount: number;

	/**
	 * このインスタンスのユーザーからフォローされている、自インスタンスのユーザーの数
	 */
	@Column('integer', {
		default: 0,
	})
	public followingCount: number;

	/**
	 * このインスタンスのユーザーをフォローしている、自インスタンスのユーザーの数
	 */
	@Column('integer', {
		default: 0,
	})
	public followersCount: number;

	/**
	 * 直近のリクエスト受信日時
	 */
	@Column('timestamp with time zone', {
		nullable: true,
	})
	public latestRequestReceivedAt: Date | null;

	/**
	 * このインスタンスと不通かどうか
	 */
	@Column('boolean', {
		default: false,
	})
	public isNotResponding: boolean;

	/**
	 * このインスタンスと不通になった日時
	 */
	@Column('timestamp with time zone', {
		nullable: true,
	})
	public notRespondingSince: Date | null;

	/**
	 * このインスタンスへの配信状態
	 */
	@Index()
	@Column('enum', {
		default: 'none',
		enum: ['none', 'manuallySuspended', 'goneSuspended', 'autoSuspendedForNotResponding'],
	})
	public suspensionState: 'none' | 'manuallySuspended' | 'goneSuspended' | 'autoSuspendedForNotResponding';

	/**
	 * True if this instance is blocked from federation.
	 */
	@Column('boolean', {
		nullable: false,
		default: false,
		comment: 'True if this instance is blocked from federation.',
	})
	public isBlocked: boolean;

	/**
	 * True if this instance is allow-listed.
	 */
	@Column('boolean', {
		nullable: false,
		default: false,
		comment: 'True if this instance is allow-listed.',
	})
	public isAllowListed: boolean;

	/**
	 * True if this instance is part of the local bubble.
	 */
	@Column('boolean', {
		nullable: false,
		default: false,
		comment: 'True if this instance is part of the local bubble.',
	})
	public isBubbled: boolean;

	/**
	 * True if this instance is silenced.
	 */
	@Column('boolean', {
		nullable: false,
		default: false,
		comment: 'True if this instance is silenced.',
	})
	public isSilenced: boolean;

	/**
	 * True if this instance is media-silenced.
	 */
	@Column('boolean', {
		nullable: false,
		default: false,
		comment: 'True if this instance is media-silenced.',
	})
	public isMediaSilenced: boolean;

	@Column('varchar', {
		length: 64, nullable: true,
		comment: 'The software of the Instance.',
	})
	public softwareName: string | null;

	@Column('varchar', {
		length: 64, nullable: true,
	})
	public softwareVersion: string | null;

	@Column('boolean', {
		nullable: true,
	})
	public openRegistrations: boolean | null;

	@Column('varchar', {
		length: 256, nullable: true,
	})
	public name: string | null;

	@Column('varchar', {
		length: 4096, nullable: true,
	})
	public description: string | null;

	@Column('varchar', {
		length: 128, nullable: true,
	})
	public maintainerName: string | null;

	@Column('varchar', {
		length: 256, nullable: true,
	})
	public maintainerEmail: string | null;

	@Column('varchar', {
		length: 256, nullable: true,
	})
	public iconUrl: string | null;

	@Column('varchar', {
		length: 256, nullable: true,
	})
	public faviconUrl: string | null;

	@Column('varchar', {
		length: 64, nullable: true,
	})
	public themeColor: string | null;

	@Column('timestamp with time zone', {
		nullable: true,
	})
	public infoUpdatedAt: Date | null;

	@Column('boolean', {
		default: false,
	})
	public isNSFW: boolean;

	@Column('boolean', {
		default: false,
	})
	public rejectReports: boolean;

	/**
	 * If true, quote posts from this instance will be downgraded to normal posts.
	 * The quote will be stripped and a process error will be generated.
	 */
	@Column('boolean', {
		default: false,
	})
	public rejectQuotes: boolean;

	@Column('varchar', {
		length: 16384, default: '',
	})
	public moderationNote: string;
}