forked from FoundKeyGang/FoundKey
30 lines
728 B
TypeScript
30 lines
728 B
TypeScript
import { Announcements } from '@/models/index.js';
|
|
import define from '@/server/api/define.js';
|
|
import { ApiError } from '@/server/api/error.js';
|
|
|
|
export const meta = {
|
|
tags: ['admin'],
|
|
|
|
requireCredential: true,
|
|
requireModerator: true,
|
|
|
|
errors: ['NO_SUCH_ANNOUNCEMENT'],
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', format: 'misskey:id' },
|
|
},
|
|
required: ['id'],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default define(meta, paramDef, async (ps) => {
|
|
const announcement = await Announcements.findOneBy({ id: ps.id });
|
|
|
|
if (announcement == null) throw new ApiError('NO_SUCH_ANNOUNCEMENT');
|
|
|
|
await Announcements.delete(announcement.id);
|
|
});
|