From 526b3ae0e49caeee05b299272e80c30f69c91d92 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Fri, 22 Sep 2023 16:52:43 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=A6=E3=83=BC=E3=82=B6=E3=82=92?= =?UTF-8?q?=E9=99=A4=E5=A4=96=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=A2=E3=83=B3?= =?UTF-8?q?=E3=83=86=E3=83=8A=20(#11277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: ユーザを除外できるアンテナ * feat(backend/api): ユーザを除外できるアンテナの作成・更新 * feat(frontend): ユーザを除外できるアンテナの作成・更新 * docs(changelog): add アンテナで一部のユーザを除外したすべてのノートから受信できるようになりました * fix: d.ts生成時にexport defaultを生成するように * fix CHANGELOG.md --------- Co-authored-by: syuilo --- CHANGELOG.md | 1 + locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + .../migration/1689325027964-UserBlacklistAnntena.js | 10 ++++++++++ packages/backend/src/core/AntennaService.ts | 6 ++++++ packages/backend/src/models/Antenna.ts | 4 ++-- packages/backend/src/models/json-schema/antenna.ts | 2 +- .../src/server/api/endpoints/antennas/create.ts | 2 +- .../src/server/api/endpoints/antennas/update.ts | 2 +- packages/frontend/src/pages/my-antennas/editor.vue | 3 ++- 10 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 packages/backend/migration/1689325027964-UserBlacklistAnntena.js diff --git a/CHANGELOG.md b/CHANGELOG.md index dc81997d41..e6c66f0859 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Feat: プロフィールでのリンク検証 - Feat: 通知をテストできるようになりました - Feat: PWAのアイコンが設定できるようになりました +- Enhance: アンテナの受信ソースに指定したユーザを除外するものを追加 - Enhance: 二要素認証設定時のセキュリティを強化 - パスワード入力が必要な操作を行う際、二要素認証が有効であれば確認コードの入力も必要になりました - Enhance: manifest.jsonをオーバーライド可能に diff --git a/locales/index.d.ts b/locales/index.d.ts index 3009c99185..f6b6daae89 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1917,6 +1917,7 @@ export interface Locale { "homeTimeline": string; "users": string; "userList": string; + "userBlacklist": string; }; "_weekday": { "sunday": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index b30fd5333d..82ced0aa3b 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1834,6 +1834,7 @@ _antennaSources: homeTimeline: "フォローしているユーザーのノート" users: "指定した一人または複数のユーザーのノート" userList: "指定したリストのユーザーのノート" + userBlacklist: "指定した一人または複数のユーザーを除いた全てのノート" _weekday: sunday: "日曜日" diff --git a/packages/backend/migration/1689325027964-UserBlacklistAnntena.js b/packages/backend/migration/1689325027964-UserBlacklistAnntena.js new file mode 100644 index 0000000000..ce246b20f8 --- /dev/null +++ b/packages/backend/migration/1689325027964-UserBlacklistAnntena.js @@ -0,0 +1,10 @@ +export class UserBlacklistAnntena1689325027964 { + name = 'UserBlacklistAnntena1689325027964' + + async up(queryRunner) { + await queryRunner.query(`ALTER TYPE "antenna_src_enum" ADD VALUE 'users_blacklist' AFTER 'list'`); + } + + async down(queryRunner) { + } +} diff --git a/packages/backend/src/core/AntennaService.ts b/packages/backend/src/core/AntennaService.ts index a7e74eeef0..841ce4b84a 100644 --- a/packages/backend/src/core/AntennaService.ts +++ b/packages/backend/src/core/AntennaService.ts @@ -119,6 +119,12 @@ export class AntennaService implements OnApplicationShutdown { return this.utilityService.getFullApAccount(username, host).toLowerCase(); }); if (!accts.includes(this.utilityService.getFullApAccount(noteUser.username, noteUser.host).toLowerCase())) return false; + } else if (antenna.src === 'users_blacklist') { + const accts = antenna.users.map(x => { + const { username, host } = Acct.parse(x); + return this.utilityService.getFullApAccount(username, host).toLowerCase(); + }); + if (accts.includes(this.utilityService.getFullApAccount(noteUser.username, noteUser.host).toLowerCase())) return false; } const keywords = antenna.keywords diff --git a/packages/backend/src/models/Antenna.ts b/packages/backend/src/models/Antenna.ts index 7c1d80cc46..dc398b6dd2 100644 --- a/packages/backend/src/models/Antenna.ts +++ b/packages/backend/src/models/Antenna.ts @@ -41,8 +41,8 @@ export class MiAntenna { }) public name: string; - @Column('enum', { enum: ['home', 'all', 'users', 'list'] }) - public src: 'home' | 'all' | 'users' | 'list'; + @Column('enum', { enum: ['home', 'all', 'users', 'list', 'users_blacklist'] }) + public src: 'home' | 'all' | 'users' | 'list' | 'users_blacklist'; @Column({ ...id(), diff --git a/packages/backend/src/models/json-schema/antenna.ts b/packages/backend/src/models/json-schema/antenna.ts index 3f58cbee6c..7b6475919c 100644 --- a/packages/backend/src/models/json-schema/antenna.ts +++ b/packages/backend/src/models/json-schema/antenna.ts @@ -47,7 +47,7 @@ export const packedAntennaSchema = { src: { type: 'string', optional: false, nullable: false, - enum: ['home', 'all', 'users', 'list'], + enum: ['home', 'all', 'users', 'list', 'users_blacklist'], }, userListId: { type: 'string', diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index f1170efe42..15fca4904d 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -47,7 +47,7 @@ export const paramDef = { type: 'object', properties: { name: { type: 'string', minLength: 1, maxLength: 100 }, - src: { type: 'string', enum: ['home', 'all', 'users', 'list'] }, + src: { type: 'string', enum: ['home', 'all', 'users', 'list', 'users_blacklist'] }, userListId: { type: 'string', format: 'misskey:id', nullable: true }, keywords: { type: 'array', items: { type: 'array', items: { diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index b020a7595f..0e98746881 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -46,7 +46,7 @@ export const paramDef = { properties: { antennaId: { type: 'string', format: 'misskey:id' }, name: { type: 'string', minLength: 1, maxLength: 100 }, - src: { type: 'string', enum: ['home', 'all', 'users', 'list'] }, + src: { type: 'string', enum: ['home', 'all', 'users', 'list', 'users_blacklist'] }, userListId: { type: 'string', format: 'misskey:id', nullable: true }, keywords: { type: 'array', items: { type: 'array', items: { diff --git a/packages/frontend/src/pages/my-antennas/editor.vue b/packages/frontend/src/pages/my-antennas/editor.vue index cd920b75e6..4add66c396 100644 --- a/packages/frontend/src/pages/my-antennas/editor.vue +++ b/packages/frontend/src/pages/my-antennas/editor.vue @@ -16,12 +16,13 @@ SPDX-License-Identifier: AGPL-3.0-only + - +