mizzkey/src/server/api/endpoints/admin/federation/update-instance.ts

34 lines
634 B
TypeScript
Raw Normal View History

import $ from 'cafy';
import define from '../../../define.js';
import { Instances } from '@/models/index.js';
import { toPuny } from '@/misc/convert-host.js';
export const meta = {
tags: ['admin'],
2020-02-15 13:33:32 +01:00
requireCredential: true as const,
requireModerator: true,
params: {
host: {
validator: $.str
},
2020-01-29 21:56:14 +01:00
isSuspended: {
validator: $.bool
},
}
};
export default define(meta, async (ps, me) => {
2019-04-09 17:59:41 +02:00
const instance = await Instances.findOne({ host: toPuny(ps.host) });
if (instance == null) {
throw new Error('instance not found');
}
2019-04-09 17:59:41 +02:00
Instances.update({ host: toPuny(ps.host) }, {
2020-01-29 21:56:14 +01:00
isSuspended: ps.isSuspended
});
});