enhance(NoteCreateService): センシティブワード・禁止ワード設定に関するログを追加 (MisskeyIO#452)

This commit is contained in:
まっちゃとーにゅ 2024-02-15 04:51:42 +09:00 committed by GitHub
parent 71b46438e7
commit 603205dfe3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -263,12 +263,14 @@ export class NoteCreateService implements OnApplicationShutdown {
const sensitiveWords = meta.sensitiveWords; const sensitiveWords = meta.sensitiveWords;
if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', sensitiveWords)) { if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', sensitiveWords)) {
data.visibility = 'home'; data.visibility = 'home';
this.logger.warn('Visibility changed to home because sensitive words are included', { user: user.id, note: data });
} else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) { } else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) {
data.visibility = 'home'; data.visibility = 'home';
} }
} }
if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) { if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) {
this.logger.error('Request rejected because prohibited words are included', { user: user.id, note: data });
throw new IdentifiableError('057d8d3e-b7ca-4f8b-b38c-dcdcbf34dc30'); throw new IdentifiableError('057d8d3e-b7ca-4f8b-b38c-dcdcbf34dc30');
} }