From d9553e73af5a64a4a32e1be35bc146ca6bd7f682 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 4 May 2023 14:20:06 +0900 Subject: [PATCH] Differentiate soft mutes and hard mutes --- packages/backend/src/misc/check-word-mute.ts | 2 +- packages/backend/src/server/api/stream/channels/antenna.ts | 4 ++-- packages/backend/src/server/api/stream/channels/channel.ts | 4 ++-- .../src/server/api/stream/channels/global-timeline.ts | 6 +++--- .../backend/src/server/api/stream/channels/home-timeline.ts | 6 +++--- .../src/server/api/stream/channels/hybrid-timeline.ts | 6 +++--- .../src/server/api/stream/channels/local-timeline.ts | 6 +++--- .../src/server/api/stream/channels/recommended-timeline.ts | 6 +++--- .../backend/src/server/api/stream/channels/user-list.ts | 4 ++-- packages/backend/src/services/note/create.ts | 4 ++-- packages/client/src/components/MkNote.vue | 4 ++-- packages/client/src/components/MkNoteDetailed.vue | 4 ++-- packages/client/src/components/MkNoteSub.vue | 4 ++-- packages/client/src/scripts/check-word-mute.ts | 2 +- 14 files changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/backend/src/misc/check-word-mute.ts b/packages/backend/src/misc/check-word-mute.ts index a411e46cc8..7d36d8f7d9 100644 --- a/packages/backend/src/misc/check-word-mute.ts +++ b/packages/backend/src/misc/check-word-mute.ts @@ -56,7 +56,7 @@ function checkWordMute(note: NoteLike): boolean { return notMuted; } -export async function getWordMute( +export async function getWordHardMute( note: NoteLike, me: UserLike | null | undefined, mutedWords: Array, diff --git a/packages/backend/src/server/api/stream/channels/antenna.ts b/packages/backend/src/server/api/stream/channels/antenna.ts index 65e1eb9879..e110c852b7 100644 --- a/packages/backend/src/server/api/stream/channels/antenna.ts +++ b/packages/backend/src/server/api/stream/channels/antenna.ts @@ -1,7 +1,7 @@ import Channel from "../channel.js"; import { Notes } from "@/models/index.js"; import { isUserRelated } from "@/misc/is-user-related.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import type { StreamMessages } from "../types.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; @@ -40,7 +40,7 @@ export default class extends Channel { if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts index 3b242bb2a4..f5c5a170d9 100644 --- a/packages/backend/src/server/api/stream/channels/channel.ts +++ b/packages/backend/src/server/api/stream/channels/channel.ts @@ -1,7 +1,7 @@ import Channel from "../channel.js"; import { Users } from "@/models/index.js"; import { isUserRelated } from "@/misc/is-user-related.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import type { User } from "@/models/entities/user.js"; import type { StreamMessages } from "../types.js"; import type { Packed } from "@/misc/schema.js"; @@ -42,7 +42,7 @@ export default class extends Channel { if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts index fb5c458b41..07ac380265 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -1,6 +1,6 @@ import Channel from "../channel.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; @@ -63,10 +63,10 @@ export default class extends Channel { // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) // 現状では、ワードミュートにおけるMutedNoteレコードの追加処理はストリーミングに流す処理と並列で行われるため、 // レコードが追加されるNoteでも追加されるより先にここのストリーミングの処理に到達することが起こる。 - // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordMuteを呼んでいる + // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordHardMuteを呼んでいる if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts index 70b2f387e1..bb79d158ce 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -1,5 +1,5 @@ import Channel from "../channel.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; import type { Packed } from "@/misc/schema.js"; @@ -61,10 +61,10 @@ export default class extends Channel { // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) // 現状では、ワードミュートにおけるMutedNoteレコードの追加処理はストリーミングに流す処理と並列で行われるため、 // レコードが追加されるNoteでも追加されるより先にここのストリーミングの処理に到達することが起こる。 - // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordMuteを呼んでいる + // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordHardMuteを呼んでいる if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts index 423fb461f3..c73eb4f700 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -1,6 +1,6 @@ import Channel from "../channel.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; import type { Packed } from "@/misc/schema.js"; @@ -78,10 +78,10 @@ export default class extends Channel { // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) // 現状では、ワードミュートにおけるMutedNoteレコードの追加処理はストリーミングに流す処理と並列で行われるため、 // レコードが追加されるNoteでも追加されるより先にここのストリーミングの処理に到達することが起こる。 - // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordMuteを呼んでいる + // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordHardMuteを呼んでいる if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts index 94901661b6..19bf43be22 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -1,6 +1,6 @@ import Channel from "../channel.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; @@ -55,10 +55,10 @@ export default class extends Channel { // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) // 現状では、ワードミュートにおけるMutedNoteレコードの追加処理はストリーミングに流す処理と並列で行われるため、 // レコードが追加されるNoteでも追加されるより先にここのストリーミングの処理に到達することが起こる。 - // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordMuteを呼んでいる + // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordHardMuteを呼んでいる if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts index 7eee22c325..cc30a85a37 100644 --- a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts @@ -1,6 +1,6 @@ import Channel from "../channel.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; import type { Packed } from "@/misc/schema.js"; @@ -76,10 +76,10 @@ export default class extends Channel { // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) // 現状では、ワードミュートにおけるMutedNoteレコードの追加処理はストリーミングに流す処理と並列で行われるため、 // レコードが追加されるNoteでも追加されるより先にここのストリーミングの処理に到達することが起こる。 - // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordMuteを呼んでいる + // そのためレコードが存在するかのチェックでは不十分なので、改めてgetWordHardMuteを呼んでいる if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index 2183351e1a..c9b658c5c7 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -2,7 +2,7 @@ import Channel from "../channel.js"; import { UserListJoinings, UserLists } from "@/models/index.js"; import type { User } from "@/models/entities/user.js"; import { isUserRelated } from "@/misc/is-user-related.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import type { Packed } from "@/misc/schema.js"; export default class extends Channel { @@ -62,7 +62,7 @@ export default class extends Channel { if ( this.userProfile && - (await getWordMute(note, this.user, this.userProfile.mutedWords)) + (await getWordHardMute(note, this.user, this.userProfile.mutedWords)) ) return; diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 7c9746b73a..d37f81ac9c 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -53,7 +53,7 @@ import { Poll } from "@/models/entities/poll.js"; import { createNotification } from "../create-notification.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import { checkHitAntenna } from "@/misc/check-hit-antenna.js"; -import { getWordMute } from "@/misc/check-word-mute.js"; +import { getWordHardMute } from "@/misc/check-word-mute.js"; import { addNoteToAntenna } from "../add-note-to-antenna.js"; import { countSameRenotes } from "@/misc/count-same-renotes.js"; import { deliverToRelays } from "../relay.js"; @@ -354,7 +354,7 @@ export default async ( ) .then((us) => { for (const u of us) { - getWordMute(note, { id: u.userId }, u.mutedWords).then( + getWordHardMute(note, { id: u.userId }, u.mutedWords).then( (shouldMute) => { if (shouldMute) { MutedNotes.insert({ diff --git a/packages/client/src/components/MkNote.vue b/packages/client/src/components/MkNote.vue index 67eab29c73..6361cad54c 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -236,7 +236,7 @@ import MkUrlPreview from "@/components/MkUrlPreview.vue"; import MkVisibility from "@/components/MkVisibility.vue"; import { pleaseLogin } from "@/scripts/please-login"; import { focusPrev, focusNext } from "@/scripts/focus"; -import { getWordMute } from "@/scripts/check-word-mute"; +import { getWordSoftMute } from "@/scripts/check-word-mute"; import { useRouter } from "@/router"; import { userPage } from "@/filters/user"; import * as os from "@/os"; @@ -305,7 +305,7 @@ let appearNote = $computed(() => const isMyRenote = $i && $i.id === note.userId; const showContent = ref(false); const isDeleted = ref(false); -const muted = ref(getWordMute(appearNote, $i, defaultStore.state.mutedWords)); +const muted = ref(getWordSoftMute(appearNote, $i, defaultStore.state.mutedWords)); const translation = ref(null); const translating = ref(false); const enableEmojiReactions = defaultStore.state.enableEmojiReactions; diff --git a/packages/client/src/components/MkNoteDetailed.vue b/packages/client/src/components/MkNoteDetailed.vue index 5c4d365789..d18f49094d 100644 --- a/packages/client/src/components/MkNoteDetailed.vue +++ b/packages/client/src/components/MkNoteDetailed.vue @@ -83,7 +83,7 @@ import MkUrlPreview from "@/components/MkUrlPreview.vue"; import MkInstanceTicker from "@/components/MkInstanceTicker.vue"; import MkVisibility from "@/components/MkVisibility.vue"; import { pleaseLogin } from "@/scripts/please-login"; -import { getWordMute } from "@/scripts/check-word-mute"; +import { getWordSoftMute } from "@/scripts/check-word-mute"; import { userPage } from "@/filters/user"; import { notePage } from "@/filters/note"; import { useRouter } from "@/router"; @@ -156,7 +156,7 @@ let appearNote = $computed(() => const isMyRenote = $i && $i.id === note.userId; const showContent = ref(false); const isDeleted = ref(false); -const muted = ref(getWordMute(appearNote, $i, defaultStore.state.mutedWords)); +const muted = ref(getWordSoftMute(appearNote, $i, defaultStore.state.mutedWords)); const translation = ref(null); const translating = ref(false); const urls = appearNote.text diff --git a/packages/client/src/components/MkNoteSub.vue b/packages/client/src/components/MkNoteSub.vue index c68f0a7360..28885c05ab 100644 --- a/packages/client/src/components/MkNoteSub.vue +++ b/packages/client/src/components/MkNoteSub.vue @@ -193,7 +193,7 @@ import XRenoteButton from "@/components/MkRenoteButton.vue"; import XQuoteButton from "@/components/MkQuoteButton.vue"; import { pleaseLogin } from "@/scripts/please-login"; import { getNoteMenu } from "@/scripts/get-note-menu"; -import { getWordMute } from "@/scripts/check-word-mute"; +import { getWordSoftMute } from "@/scripts/check-word-mute"; import { notePage } from "@/filters/note"; import { useRouter } from "@/router"; import * as os from "@/os"; @@ -255,7 +255,7 @@ let appearNote = $computed(() => isRenote ? (note.renote as misskey.entities.Note) : note ); const isDeleted = ref(false); -const muted = ref(getWordMute(appearNote, $i, defaultStore.state.mutedWords)); +const muted = ref(getWordSoftMute(appearNote, $i, defaultStore.state.mutedWords)); const translation = ref(null); const translating = ref(false); const replies: misskey.entities.Note[] = diff --git a/packages/client/src/scripts/check-word-mute.ts b/packages/client/src/scripts/check-word-mute.ts index f5d0ac86f7..d2cd643249 100644 --- a/packages/client/src/scripts/check-word-mute.ts +++ b/packages/client/src/scripts/check-word-mute.ts @@ -46,7 +46,7 @@ function checkWordMute(note: NoteLike): Muted { } } -export function getWordMute( +export function getWordSoftMute( note: Record, me: Record | null | undefined, mutedWords: Array,