mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-15 07:53:08 +02:00
35 lines
754 B
TypeScript
35 lines
754 B
TypeScript
|
import $ from 'cafy';
|
||
|
import define from '../../../define';
|
||
|
import { ID } from '../../../../../misc/cafy-id';
|
||
|
import { Announcements } from '../../../../../models';
|
||
|
import { ApiError } from '../../../error';
|
||
|
|
||
|
export const meta = {
|
||
|
tags: ['admin'],
|
||
|
|
||
|
requireCredential: true,
|
||
|
requireModerator: true,
|
||
|
|
||
|
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);
|
||
|
});
|