From 9c448055a3f4bf9de5ba9fff2746cb2f25bcaf47 Mon Sep 17 00:00:00 2001 From: nenohi Date: Fri, 29 Sep 2023 12:27:05 +0900 Subject: [PATCH] =?UTF-8?q?=E5=BA=83=E5=91=8A=E3=81=AB=E9=96=A2=E3=81=99?= =?UTF-8?q?=E3=82=8B=E4=BF=AE=E6=AD=A3(=E9=85=8D=E4=BF=A1=E4=B8=AD?= =?UTF-8?q?=E3=81=AE=E7=B5=9E=E3=82=8A=E8=BE=BC=E3=81=BF=E3=80=81Create?= =?UTF-8?q?=E6=99=82=E3=81=ABMiAd=E3=82=92=E8=BF=94=E3=81=99=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB)=20(#11913)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ad/createにて作成したMiAdを返すように 別なツールからアップデート等をする際に必要 * ad/list取得に現在掲載中のオプションを作成 * スイッチで配信中のみを絞れるように * update CHANGELOG * エラー修正 * Update packages/frontend/src/pages/admin/ads.vue --------- Co-authored-by: syuilo --- CHANGELOG.md | 2 ++ .../server/api/endpoints/admin/ad/create.ts | 5 +-- .../src/server/api/endpoints/admin/ad/list.ts | 4 +++ packages/frontend/src/pages/admin/ads.vue | 32 ++++++++++++++----- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5dea03e63..64cfbbf9fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,9 +24,11 @@ ### Client - Enhance: モデレーションログ機能の強化 - Enhance: Plugin:register_post_form_actionを用いてCWを取得・変更できるように +- Feat:admin/ad/listにて掲載中の広告が絞り込めるように ### Server - Enhance: MasterプロセスのPIDを書き出せるように +- Feat:admin/ad/createにてレスポンス200、設定した広告情報を返すように ## 2023.9.1 diff --git a/packages/backend/src/server/api/endpoints/admin/ad/create.ts b/packages/backend/src/server/api/endpoints/admin/ad/create.ts index a13d08fd3a..2ed9410e78 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/create.ts @@ -41,7 +41,7 @@ export default class extends Endpoint { // eslint- private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { - await this.adsRepository.insert({ + const ad = await this.adsRepository.insert({ id: this.idService.genId(), createdAt: new Date(), expiresAt: new Date(ps.expiresAt), @@ -53,7 +53,8 @@ export default class extends Endpoint { // eslint- ratio: ps.ratio, place: ps.place, memo: ps.memo, - }); + }).then(r => this.adsRepository.findOneByOrFail({ id: r.identifiers[0].id })); + return ad; }); } } diff --git a/packages/backend/src/server/api/endpoints/admin/ad/list.ts b/packages/backend/src/server/api/endpoints/admin/ad/list.ts index adff3ed0ae..29eff89523 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/list.ts @@ -22,6 +22,7 @@ export const paramDef = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, + publishing: { type: 'boolean', default: false }, }, required: [], } as const; @@ -36,6 +37,9 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const query = this.queryService.makePaginationQuery(this.adsRepository.createQueryBuilder('ad'), ps.sinceId, ps.untilId); + if (ps.publishing) { + query.andWhere('ad.expiresAt > :now', { now: new Date() }).andWhere('ad.startsAt <= :now', { now: new Date() }); + } const ads = await query.limit(ps.limit).getMany(); return ads; diff --git a/packages/frontend/src/pages/admin/ads.vue b/packages/frontend/src/pages/admin/ads.vue index cd9d86ca45..6aa0cf0427 100644 --- a/packages/frontend/src/pages/admin/ads.vue +++ b/packages/frontend/src/pages/admin/ads.vue @@ -5,11 +5,16 @@ SPDX-License-Identifier: AGPL-3.0-only