From 6b676a928d3e167c98f2a1854a432adf5c125d65 Mon Sep 17 00:00:00 2001 From: yupix Date: Sun, 10 Mar 2024 17:31:39 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20antennas/update=E3=81=AE?= =?UTF-8?q?=E5=BF=85=E9=A0=88=E9=A0=85=E7=9B=AE=E3=82=92antennaId=E3=81=AE?= =?UTF-8?q?=E3=81=BF=E3=81=AB=20(#13542)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: antennas/updateの必須項目を最小限に * fix: userListIdがnullにできない --- CHANGELOG.md | 2 +- .../server/api/endpoints/antennas/update.ts | 12 +++++++----- packages/misskey-js/src/autogen/types.ts | 18 +++++++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be621e1ebd..8c5f05dbe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ - Fix: カスタム絵文字の画像読み込みに失敗した際はテキストではなくダミー画像を表示 #13487 ### Server -- +- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに ## 2024.3.0 diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 459729f61f..76a34924a0 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -67,7 +67,7 @@ export const paramDef = { withFile: { type: 'boolean' }, notify: { type: 'boolean' }, }, - required: ['antennaId', 'name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'], + required: ['antennaId'], } as const; @Injectable() @@ -83,8 +83,10 @@ export default class extends Endpoint { // eslint- private globalEventService: GlobalEventService, ) { super(meta, paramDef, async (ps, me) => { - if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) { - throw new Error('either keywords or excludeKeywords is required.'); + if (ps.keywords && ps.excludeKeywords) { + if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) { + throw new Error('either keywords or excludeKeywords is required.'); + } } // Fetch the antenna const antenna = await this.antennasRepository.findOneBy({ @@ -98,7 +100,7 @@ export default class extends Endpoint { // eslint- let userList; - if (ps.src === 'list' && ps.userListId) { + if ((ps.src === 'list' || antenna.src === 'list') && ps.userListId) { userList = await this.userListsRepository.findOneBy({ id: ps.userListId, userId: me.id, @@ -112,7 +114,7 @@ export default class extends Endpoint { // eslint- await this.antennasRepository.update(antenna.id, { name: ps.name, src: ps.src, - userListId: userList ? userList.id : null, + userListId: ps.userListId !== undefined ? userList ? userList.id : null : undefined, keywords: ps.keywords, excludeKeywords: ps.excludeKeywords, users: ps.users, diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 41c3f50135..be3e86bd78 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -9925,19 +9925,19 @@ export type operations = { 'application/json': { /** Format: misskey:id */ antennaId: string; - name: string; + name?: string; /** @enum {string} */ - src: 'home' | 'all' | 'users' | 'list' | 'users_blacklist'; + src?: 'home' | 'all' | 'users' | 'list' | 'users_blacklist'; /** Format: misskey:id */ userListId?: string | null; - keywords: string[][]; - excludeKeywords: string[][]; - users: string[]; - caseSensitive: boolean; + keywords?: string[][]; + excludeKeywords?: string[][]; + users?: string[]; + caseSensitive?: boolean; localOnly?: boolean; - withReplies: boolean; - withFile: boolean; - notify: boolean; + withReplies?: boolean; + withFile?: boolean; + notify?: boolean; }; }; };