diff options
| author | おさむのひと <46447427+samunohito@users.noreply.github.com> | 2024-02-09 10:07:18 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-09 10:07:18 +0900 |
| commit | 614c9a0fc602586710e3f24bb26140bb49c2d54a (patch) | |
| tree | 23e615d5f2ed545160612d5ac57bdba0c551ef18 /packages/backend/src/core/NoteCreateService.ts | |
| parent | chore: use vite@5.1.0 / pnpm@8.15.1 (diff) | |
| download | sharkey-614c9a0fc602586710e3f24bb26140bb49c2d54a.tar.gz sharkey-614c9a0fc602586710e3f24bb26140bb49c2d54a.tar.bz2 sharkey-614c9a0fc602586710e3f24bb26140bb49c2d54a.zip | |
fix: 特定文字列を含むノートを投稿できないようにする管理画面用設定項目を追加 (#13210)
* fix: 特定文字列を含むノートを投稿できないようにする管理画面用設定項目を追加
* Serviceでチェックするように変更
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index f7e870831d..153a6406a9 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -151,6 +151,8 @@ type Option = { export class NoteCreateService implements OnApplicationShutdown { #shutdownController = new AbortController(); + public static ContainsProhibitedWordsError = class extends Error {}; + constructor( @Inject(DI.config) private config: Config, @@ -254,13 +256,19 @@ export class NoteCreateService implements OnApplicationShutdown { if (data.visibility === 'public' && data.channel == null) { const sensitiveWords = meta.sensitiveWords; - if (this.utilityService.isSensitiveWordIncluded(data.cw ?? data.text ?? '', sensitiveWords)) { + if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', sensitiveWords)) { data.visibility = 'home'; } else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) { data.visibility = 'home'; } } + if (!user.host) { + if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) { + throw new NoteCreateService.ContainsProhibitedWordsError(); + } + } + const inSilencedInstance = this.utilityService.isSilencedHost(meta.silencedHosts, user.host); if (data.visibility === 'public' && inSilencedInstance && user.host !== null) { |