2020-01-29 21:37:25 +02:00
|
|
|
import $ from 'cafy';
|
|
|
|
import define from '../../../define';
|
2021-03-23 10:43:07 +02:00
|
|
|
import { ID } from '@/misc/cafy-id';
|
2020-01-29 21:37:25 +02:00
|
|
|
import { Announcements } from '../../../../../models';
|
|
|
|
import { ApiError } from '../../../error';
|
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
2020-02-15 14:33:32 +02:00
|
|
|
requireCredential: true as const,
|
2020-01-29 21:37:25 +02:00
|
|
|
requireModerator: true,
|
|
|
|
|
2021-03-06 15:34:11 +02:00
|
|
|
desc: {
|
|
|
|
'ja-JP': 'アナウンスを削除します。',
|
|
|
|
'en-US': 'Delete a announcement.'
|
|
|
|
},
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
params: {
|
|
|
|
id: {
|
|
|
|
validator: $.type(ID)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
noSuchAnnouncement: {
|
|
|
|
message: 'No such announcement.',
|
|
|
|
code: 'NO_SUCH_ANNOUNCEMENT',
|
|
|
|
id: 'ecad8040-a276-4e85-bda9-015a708d291e'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default define(meta, async (ps, me) => {
|
|
|
|
const announcement = await Announcements.findOne(ps.id);
|
|
|
|
|
|
|
|
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
|
|
|
|
|
|
|
await Announcements.delete(announcement.id);
|
|
|
|
});
|