summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteCreateService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-12-27 21:28:38 +0900
committerGitHub <noreply@github.com>2023-12-27 21:28:38 +0900
commit53898c50066366b23c507775c655599587a91673 (patch)
tree537c9ef74f189bf9984ef3f0c3da4eded1a4aec9 /packages/backend/src/core/NoteCreateService.ts
parentMerge pull request #12564 from misskey-dev/develop (diff)
parent2023.12.1 (diff)
downloadmisskey-53898c50066366b23c507775c655599587a91673.tar.gz
misskey-53898c50066366b23c507775c655599587a91673.tar.bz2
misskey-53898c50066366b23c507775c655599587a91673.zip
Merge pull request #12771 from misskey-dev/develop
Release: 2023.12.1
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
-rw-r--r--packages/backend/src/core/NoteCreateService.ts28
1 files changed, 2 insertions, 26 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index 2bdff872ad..ed8d51df16 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -253,7 +253,7 @@ export class NoteCreateService implements OnApplicationShutdown {
if (data.visibility === 'public' && data.channel == null) {
const sensitiveWords = meta.sensitiveWords;
- if (this.isSensitive(data, sensitiveWords)) {
+ if (this.utilityService.isSensitiveWordIncluded(data.cw ?? data.text ?? '', sensitiveWords)) {
data.visibility = 'home';
} else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) {
data.visibility = 'home';
@@ -705,31 +705,6 @@ export class NoteCreateService implements OnApplicationShutdown {
}
@bindThis
- private isSensitive(note: Option, sensitiveWord: string[]): boolean {
- if (sensitiveWord.length > 0) {
- const text = note.cw ?? note.text ?? '';
- if (text === '') return false;
- const matched = sensitiveWord.some(filter => {
- // represents RegExp
- const regexp = filter.match(/^\/(.+)\/(.*)$/);
- // This should never happen due to input sanitisation.
- if (!regexp) {
- const words = filter.split(' ');
- return words.every(keyword => text.includes(keyword));
- }
- try {
- return new RE2(regexp[1], regexp[2]).test(text);
- } catch (err) {
- // This should never happen due to input sanitisation.
- return false;
- }
- });
- if (matched) return true;
- }
- return false;
- }
-
- @bindThis
private isQuote(note: Option): note is Option & { renote: MiNote } {
// sync with misc/is-quote.ts
return !!note.renote && (!!note.text || !!note.cw || (!!note.files && !!note.files.length) || !!note.poll);
@@ -912,6 +887,7 @@ export class NoteCreateService implements OnApplicationShutdown {
// ダイレクトのとき、そのリストが対象外のユーザーの場合
if (
note.visibility === 'specified' &&
+ note.userId !== userListMembership.userListUserId &&
!note.visibleUserIds.some(v => v === userListMembership.userListUserId)
) continue;