2021-08-19 15:55:45 +03:00
|
|
|
import define from '../../../define';
|
|
|
|
import { Announcements } from '@/models/index';
|
|
|
|
import { ApiError } from '../../../error';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
2022-01-18 15:27:10 +02:00
|
|
|
requireCredential: true,
|
2020-01-29 21:37:25 +02:00
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
noSuchAnnouncement: {
|
|
|
|
message: 'No such announcement.',
|
|
|
|
code: 'NO_SUCH_ANNOUNCEMENT',
|
2021-12-09 16:58:30 +02:00
|
|
|
id: 'ecad8040-a276-4e85-bda9-015a708d291e',
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 15:27:10 +02:00
|
|
|
} as const;
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2022-02-19 07:05:32 +02:00
|
|
|
const paramDef = {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
id: { type: 'string', format: 'misskey:id' },
|
|
|
|
},
|
|
|
|
required: ['id'],
|
|
|
|
} as const;
|
|
|
|
|
2022-01-02 19:12:50 +02:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 07:05:32 +02:00
|
|
|
export default define(meta, paramDef, async (ps, me) => {
|
2020-01-29 21:37:25 +02:00
|
|
|
const announcement = await Announcements.findOne(ps.id);
|
|
|
|
|
|
|
|
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
|
|
|
|
|
|
|
await Announcements.delete(announcement.id);
|
|
|
|
});
|