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