2022-02-27 02:07:39 +00:00
|
|
|
import define from '../../../define.js';
|
|
|
|
import { Ads } from '@/models/index.js';
|
|
|
|
import { ApiError } from '../../../error.js';
|
2021-05-04 12:15:57 +00:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
2022-01-18 13:27:10 +00:00
|
|
|
requireCredential: true,
|
2021-05-04 12:15:57 +00:00
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
noSuchAd: {
|
|
|
|
message: 'No such ad.',
|
|
|
|
code: 'NO_SUCH_AD',
|
2021-12-09 14:58:30 +00:00
|
|
|
id: 'ccac9863-3a03-416e-b899-8a64041118b1',
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 13:27:10 +00:00
|
|
|
} as const;
|
2021-05-04 12:15:57 +00:00
|
|
|
|
2022-02-20 04:15:40 +00:00
|
|
|
export const paramDef = {
|
2022-02-19 05:05:32 +00:00
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
id: { type: 'string', format: 'misskey:id' },
|
|
|
|
},
|
|
|
|
required: ['id'],
|
|
|
|
} as const;
|
|
|
|
|
2022-01-02 17:12:50 +00:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 05:05:32 +00:00
|
|
|
export default define(meta, paramDef, async (ps, me) => {
|
2021-05-04 12:15:57 +00:00
|
|
|
const ad = await Ads.findOne(ps.id);
|
|
|
|
|
|
|
|
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
|
|
|
|
|
|
|
await Ads.delete(ad.id);
|
|
|
|
});
|