summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/admin/ad/update.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-11-12 02:02:25 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-11-12 02:02:25 +0900
commit0e4a111f81cceed275d9bec2695f6e401fb654d8 (patch)
tree40874799472fa07416f17b50a398ac33b7771905 /src/server/api/endpoints/admin/ad/update.ts
parentupdate deps (diff)
downloadsharkey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.gz
sharkey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.bz2
sharkey-0e4a111f81cceed275d9bec2695f6e401fb654d8.zip
refactoring
Resolve #7779
Diffstat (limited to 'src/server/api/endpoints/admin/ad/update.ts')
-rw-r--r--src/server/api/endpoints/admin/ad/update.ts63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/server/api/endpoints/admin/ad/update.ts b/src/server/api/endpoints/admin/ad/update.ts
deleted file mode 100644
index 36c87895c2..0000000000
--- a/src/server/api/endpoints/admin/ad/update.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Ads } from '@/models/index';
-import { ApiError } from '../../../error';
-
-export const meta = {
- tags: ['admin'],
-
- requireCredential: true as const,
- requireModerator: true,
-
- params: {
- id: {
- validator: $.type(ID)
- },
- memo: {
- validator: $.str
- },
- url: {
- validator: $.str.min(1)
- },
- imageUrl: {
- validator: $.str.min(1)
- },
- place: {
- validator: $.str
- },
- priority: {
- validator: $.str
- },
- ratio: {
- validator: $.num.int().min(0)
- },
- expiresAt: {
- validator: $.num.int()
- },
- },
-
- errors: {
- noSuchAd: {
- message: 'No such ad.',
- code: 'NO_SUCH_AD',
- id: 'b7aa1727-1354-47bc-a182-3a9c3973d300'
- }
- }
-};
-
-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.update(ad.id, {
- url: ps.url,
- place: ps.place,
- priority: ps.priority,
- ratio: ps.ratio,
- memo: ps.memo,
- imageUrl: ps.imageUrl,
- expiresAt: new Date(ps.expiresAt),
- });
-});