From 7945708de1aeeddf79cfafff957cb9f4daa1a582 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 21 Feb 2024 23:10:25 +0900 Subject: [PATCH 1/6] refactor: use IdentifiableError instead of NoteCreateService.ContainsProhibitedWordsError --- packages/backend/src/core/NoteCreateService.ts | 4 +--- packages/backend/src/server/api/endpoints/notes/create.ts | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 6a8de8677a07..9268516afcf5 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -155,8 +155,6 @@ export class NoteCreateService implements OnApplicationShutdown { private logger: Logger; #shutdownController = new AbortController(); - public static ContainsProhibitedWordsError = class extends Error {}; - constructor( @Inject(DI.config) private config: Config, @@ -271,7 +269,7 @@ export class NoteCreateService implements OnApplicationShutdown { } if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) { - throw new NoteCreateService.ContainsProhibitedWordsError(); + throw new IdentifiableError('689ee33f-f97c-479a-ac49-1b9f8140af99', 'Note contains prohibited words'); } const inSilencedInstance = this.utilityService.isSilencedHost(meta.silencedHosts, user.host); diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index e6e4fcc745fd..25eeede71eed 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -20,6 +20,7 @@ import { isPureRenote } from '@/misc/is-pure-renote.js'; import { MetaService } from '@/core/MetaService.js'; import { UtilityService } from '@/core/UtilityService.js'; import { ApiError } from '../../error.js'; +import {IdentifiableError} from "@/misc/identifiable-error.js"; export const meta = { tags: ['notes'], @@ -376,8 +377,8 @@ export default class extends Endpoint { // eslint- }; } catch (e) { // TODO: 他のErrorもここでキャッチしてエラーメッセージを当てるようにしたい - if (e instanceof NoteCreateService.ContainsProhibitedWordsError) { - throw new ApiError(meta.errors.containsProhibitedWords); + if (e instanceof IdentifiableError) { + if (e.id === '689ee33f-f97c-479a-ac49-1b9f8140af99') throw new ApiError(meta.errors.containsProhibitedWords); } throw e; From e84f8c4a9e5efde304fbc86d1a101e6fd4f07760 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 21 Feb 2024 23:13:55 +0900 Subject: [PATCH 2/6] fix: mentions from unfamiliar user and notes with prohibited words are reprocessed with delay --- .../src/queue/processors/InboxProcessorService.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts index 7adadd799b7a..778df6e4b255 100644 --- a/packages/backend/src/queue/processors/InboxProcessorService.ts +++ b/packages/backend/src/queue/processors/InboxProcessorService.ts @@ -24,6 +24,7 @@ import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js'; import { LdSignatureService } from '@/core/activitypub/LdSignatureService.js'; import { ApInboxService } from '@/core/activitypub/ApInboxService.js'; import { bindThis } from '@/decorators.js'; +import { IdentifiableError } from '@/misc/identifiable-error.js'; import { QueueLoggerService } from '../QueueLoggerService.js'; import type { InboxJobData } from '../types.js'; @@ -180,7 +181,14 @@ export class InboxProcessorService { }); // アクティビティを処理 - await this.apInboxService.performActivity(authUser.user, activity); + try { + await this.apInboxService.performActivity(authUser.user, activity); + } catch (e) { + if (e instanceof IdentifiableError) { + if (e.id === 'e11b3a16-f543-4885-8eb1-66cad131dbfd') return 'blocked mentions from unfamiliar user'; + if (e.id === '689ee33f-f97c-479a-ac49-1b9f8140af99') return 'blocked notes with prohibited words'; + } + } return 'ok'; } } From 3c02ccc654462ca2f91e2289b76ea6879cd05fa3 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:32:51 +0900 Subject: [PATCH 3/6] docs(changelog): update changelog --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 033db6115e8d..cc71643565cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,18 @@ --> +## 202x.x.x (unreleased) + +### General +- + +### Client +- + +### Server +- 禁止ワード設定によってリモートの投稿がブロックされると、InboxキューにDelayed Jobとして残ってしまう問題を修正 +- ローカルユーザーがまだ誰もフォローしていないリモートユーザーによる、通知を引き起こす可能性のある投稿を拒否すると、InboxキューにDelayed Jobとして残ってしまう問題を修正 + ## 2024.2.0-kinel.2 ### Server From aa5a7faf76045d866476ee8dccd487b7574b5bf3 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 21 Feb 2024 23:48:16 +0900 Subject: [PATCH 4/6] lint: fix lint errors --- packages/backend/src/server/api/endpoints/notes/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 25eeede71eed..2fa0bd099fe7 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -19,8 +19,8 @@ import { DI } from '@/di-symbols.js'; import { isPureRenote } from '@/misc/is-pure-renote.js'; import { MetaService } from '@/core/MetaService.js'; import { UtilityService } from '@/core/UtilityService.js'; +import { IdentifiableError } from '@/misc/identifiable-error.js'; import { ApiError } from '../../error.js'; -import {IdentifiableError} from "@/misc/identifiable-error.js"; export const meta = { tags: ['notes'], From 127018dd3a92832b571ed818d95c667055cfd715 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 21 Feb 2024 23:51:03 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20rethrow=E3=81=99=E3=82=8B=E3=81=B9?= =?UTF-8?q?=E3=81=8D=E3=81=AA=E3=81=AE=E3=81=ABrethrow=E3=81=97=E5=BF=98?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/queue/processors/InboxProcessorService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts index 778df6e4b255..1305ba184be7 100644 --- a/packages/backend/src/queue/processors/InboxProcessorService.ts +++ b/packages/backend/src/queue/processors/InboxProcessorService.ts @@ -188,6 +188,7 @@ export class InboxProcessorService { if (e.id === 'e11b3a16-f543-4885-8eb1-66cad131dbfd') return 'blocked mentions from unfamiliar user'; if (e.id === '689ee33f-f97c-479a-ac49-1b9f8140af99') return 'blocked notes with prohibited words'; } + throw e; } return 'ok'; } From 9a7a00cccfbb3803658e7ab7b936216c7866fe6a Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:56:27 +0900 Subject: [PATCH 6/6] fix(changelog): style was wrong --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc71643565cd..b16358b9f02d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,8 @@ - ### Server -- 禁止ワード設定によってリモートの投稿がブロックされると、InboxキューにDelayed Jobとして残ってしまう問題を修正 -- ローカルユーザーがまだ誰もフォローしていないリモートユーザーによる、通知を引き起こす可能性のある投稿を拒否すると、InboxキューにDelayed Jobとして残ってしまう問題を修正 +- Fix: 禁止ワード設定によってリモートの投稿がブロックされると、InboxキューにDelayed Jobとして残ってしまう問題を修正 +- Fix: ローカルユーザーがまだ誰もフォローしていないリモートユーザーによる、通知を引き起こす可能性のある投稿を拒否すると、InboxキューにDelayed Jobとして残ってしまう問題を修正 ## 2024.2.0-kinel.2