summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/admin/federation/update-instance.ts
blob: 7206e4fb2ed015605ed151e703827aa50f8ac8ac (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
import $ from 'cafy';
import define from '../../../define';
import { Instances } from '../../../../../models';
import { toPuny } from '../../../../../misc/convert-host';

export const meta = {
	desc: {
		'ja-JP': '指定したドメインのアクティビティの配信を停止するかを選択します。',
		'en-US': 'Select whether to undeliver the activity for the specified domain.'
	},

	tags: ['admin'],

	requireCredential: true as const,
	requireModerator: true,

	params: {
		host: {
			validator: $.str
		},

		isSuspended: {
			validator: $.bool
		},
	}
};

export default define(meta, async (ps, me) => {
	const instance = await Instances.findOne({ host: toPuny(ps.host) });

	if (instance == null) {
		throw new Error('instance not found');
	}

	Instances.update({ host: toPuny(ps.host) }, {
		isSuspended: ps.isSuspended
	});
});