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

34 lines
625 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 12:33:32 +00:00
requireCredential: true as const,
requireModerator: true,
params: {
host: {
validator: $.str
},
2020-01-29 20:56:14 +00:00
isSuspended: {
validator: $.bool
},
}
};
export default define(meta, async (ps, me) => {
2019-04-09 15:59:41 +00:00
const instance = await Instances.findOne({ host: toPuny(ps.host) });
if (instance == null) {
throw new Error('instance not found');
}
2019-04-09 15:59:41 +00:00
Instances.update({ host: toPuny(ps.host) }, {
2020-01-29 20:56:14 +00:00
isSuspended: ps.isSuspended
});
});