2022-02-27 03:07:39 +01:00
|
|
|
import define from '../../../define.js';
|
|
|
|
import { Ads } from '@/models/index.js';
|
|
|
|
import { genId } from '@/misc/gen-id.js';
|
2021-05-04 14:15:57 +02:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
2022-01-18 14:27:10 +01:00
|
|
|
requireCredential: true,
|
2021-05-04 14:15:57 +02:00
|
|
|
requireModerator: true,
|
2022-02-19 06:05:32 +01:00
|
|
|
} as const;
|
2021-05-04 14:15:57 +02:00
|
|
|
|
2022-02-20 05:15:40 +01:00
|
|
|
export const paramDef = {
|
2022-02-19 06:05:32 +01:00
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
url: { type: 'string', minLength: 1 },
|
|
|
|
memo: { type: 'string' },
|
|
|
|
place: { type: 'string' },
|
|
|
|
priority: { type: 'string' },
|
|
|
|
ratio: { type: 'integer' },
|
|
|
|
expiresAt: { type: 'integer' },
|
|
|
|
imageUrl: { type: 'string', minLength: 1 },
|
2021-05-04 14:15:57 +02:00
|
|
|
},
|
2022-02-19 06:05:32 +01:00
|
|
|
required: ['url', 'memo', 'place', 'priority', 'ratio', 'expiresAt', 'imageUrl'],
|
2022-01-18 14:27:10 +01:00
|
|
|
} as const;
|
2021-05-04 14:15:57 +02:00
|
|
|
|
2022-01-02 18:12:50 +01:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 06:05:32 +01:00
|
|
|
export default define(meta, paramDef, async (ps) => {
|
2021-05-04 14:15:57 +02:00
|
|
|
await Ads.insert({
|
|
|
|
id: genId(),
|
|
|
|
createdAt: new Date(),
|
|
|
|
expiresAt: new Date(ps.expiresAt),
|
|
|
|
url: ps.url,
|
|
|
|
imageUrl: ps.imageUrl,
|
|
|
|
priority: ps.priority,
|
2021-05-07 07:22:13 +02:00
|
|
|
ratio: ps.ratio,
|
2021-05-04 14:15:57 +02:00
|
|
|
place: ps.place,
|
|
|
|
memo: ps.memo,
|
|
|
|
});
|
|
|
|
});
|