Ad (#7495)
* wip * Update ad.vue * Update default.widgets.vue * wip * Create 1620019354680-ad.ts * wip * Update ads.vue * wip * Update ad.vue
This commit is contained in:
parent
71ebb068f7
commit
18e1efc7ec
24 changed files with 596 additions and 27 deletions
34
src/server/api/endpoints/admin/ad/delete.ts
Normal file
34
src/server/api/endpoints/admin/ad/delete.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { Ads } from '../../../../../models';
|
||||
import { ApiError } from '../../../error';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true as const,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
id: {
|
||||
validator: $.type(ID)
|
||||
}
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchAd: {
|
||||
message: 'No such ad.',
|
||||
code: 'NO_SUCH_AD',
|
||||
id: 'ccac9863-3a03-416e-b899-8a64041118b1'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue