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

34 lines
629 B
TypeScript
Raw Normal View History

import $ from 'cafy';
import define from '../../../define';
import { Instances } from '@/models/index';
import { toPuny } from '@/misc/convert-host';
export const meta = {
tags: ['admin'],
2020-02-15 13:33:32 +01:00
requireCredential: true as const,
requireModerator: true,
params: {
host: {
2021-12-09 15:58:30 +01:00
validator: $.str,
},
2020-01-29 21:56:14 +01:00
isSuspended: {
2021-12-09 15:58:30 +01:00
validator: $.bool,
},
2021-12-09 15:58:30 +01:00
},
};
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) }, {
2021-12-09 15:58:30 +01:00
isSuspended: ps.isSuspended,
});
});