2021-05-04 12:15:57 +00:00
|
|
|
import $ from 'cafy';
|
2021-08-19 12:55:45 +00:00
|
|
|
import define from '../../../define';
|
|
|
|
import { ID } from '@/misc/cafy-id';
|
|
|
|
import { Ads } from '@/models/index';
|
|
|
|
import { ApiError } from '../../../error';
|
2021-05-04 12:15:57 +00:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
|
|
|
requireCredential: true as const,
|
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
id: {
|
2021-12-09 14:58:30 +00:00
|
|
|
validator: $.type(ID),
|
|
|
|
},
|
2021-05-04 12:15:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
noSuchAd: {
|
|
|
|
message: 'No such ad.',
|
|
|
|
code: 'NO_SUCH_AD',
|
2021-12-09 14:58:30 +00:00
|
|
|
id: 'ccac9863-3a03-416e-b899-8a64041118b1',
|
|
|
|
},
|
|
|
|
},
|
2021-05-04 12:15:57 +00:00
|
|
|
};
|
|
|
|
|
2022-01-02 17:12:50 +00:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2021-05-04 12:15:57 +00:00
|
|
|
export default define(meta, async (ps, me) => {
|
|
|
|
const ad = await Ads.findOne(ps.id);
|
|
|
|
|
|
|
|
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
|
|
|
|
|
|
|
await Ads.delete(ad.id);
|
|
|
|
});
|