From e5c060eecf3be33c26f4909a933d1884fda4eee3 Mon Sep 17 00:00:00 2001 From: Marie Date: Fri, 26 Jan 2024 01:59:19 +0100 Subject: fix: don't show mentions and boosts towards muted user posts in timeline Closes #336 --- packages/backend/src/server/api/stream/channels/bubble-timeline.ts | 3 +++ packages/backend/src/server/api/stream/channels/global-timeline.ts | 3 +++ packages/backend/src/server/api/stream/channels/home-timeline.ts | 3 +++ packages/backend/src/server/api/stream/channels/hybrid-timeline.ts | 3 +++ packages/backend/src/server/api/stream/channels/local-timeline.ts | 3 +++ 5 files changed, 15 insertions(+) (limited to 'packages/backend/src/server/api/stream') diff --git a/packages/backend/src/server/api/stream/channels/bubble-timeline.ts b/packages/backend/src/server/api/stream/channels/bubble-timeline.ts index 4f8809edbe..2d85d65ba5 100644 --- a/packages/backend/src/server/api/stream/channels/bubble-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/bubble-timeline.ts @@ -78,6 +78,9 @@ class BubbleTimelineChannel extends Channel { // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoBlockingMe)) return; + if (note.renote && !note.text && note.renote.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; if (this.user && note.renoteId && !note.text) { 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 e05e380aae..17019e2ec6 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -74,6 +74,9 @@ class GlobalTimelineChannel extends Channel { // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoBlockingMe)) return; + if (note.renote && !note.text && note.renote.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; if (this.user && note.renoteId && !note.text) { 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 3b499b7bf3..a48968663a 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -79,6 +79,9 @@ class HomeTimelineChannel extends Channel { if (isUserRelated(note, this.userIdsWhoMeMuting)) return; // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoBlockingMe)) return; + + if (note.renote && !note.text && note.renote.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) 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 26cbbebe83..e2e3a261be 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -97,6 +97,9 @@ class HybridTimelineChannel extends Channel { // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoBlockingMe)) return; + if (note.renote && !note.text && note.renote.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; if (this.user && note.renoteId && !note.text) { 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 40342b6c7b..24920ee4b2 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -73,6 +73,9 @@ class LocalTimelineChannel extends Channel { // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoBlockingMe)) return; + if (note.renote && !note.text && note.renote.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.mentions?.some(mention => this.userIdsWhoMeMuting.has(mention))) return; + if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; if (this.user && note.renoteId && !note.text) { -- cgit v1.2.3-freya