From 32a4875162b952d30e4afb6ea3efddb1b42b141e Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 6 May 2024 23:19:56 +0200 Subject: [PATCH] [backend/streaming] Enforce notification blocks/mutes in StreamingConnectionAggregate --- .../Hubs/Helpers/StreamingConnectionAggregate.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs b/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs index 835976a3..54a77a71 100644 --- a/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs +++ b/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs @@ -124,6 +124,7 @@ public sealed class StreamingConnectionAggregate : IDisposable try { if (notification.NotifieeId != _userId) return; + if (notification.Notifier != null && IsFiltered(notification.Notifier)) return; await using var scope = GetTempScope(); var renderer = scope.ServiceProvider.GetRequiredService(); @@ -199,14 +200,12 @@ public sealed class StreamingConnectionAggregate : IDisposable } [SuppressMessage("ReSharper", "SuggestBaseTypeForParameter")] - private bool IsFiltered(Note note) - { - if (!_blockedBy.Contains(note.User.Id) && - !_blocking.Contains(note.User.Id) && - !_muting.Contains(note.User.Id)) return true; + private bool IsFiltered(Note note) => + IsFiltered(note.User) || _blocking.Intersects(note.Mentions) || _muting.Intersects(note.Mentions); - return _blocking.Intersects(note.Mentions) || _muting.Intersects(note.Mentions); - } + [SuppressMessage("ReSharper", "SuggestBaseTypeForParameter")] + private bool IsFiltered(User user) => + !_blockedBy.Contains(user.Id) && !_blocking.Contains(user.Id) && !_muting.Contains(user.Id); [SuppressMessage("ReSharper", "SuggestBaseTypeForParameter")] private bool IsFollowingOrSelf(User user) => user.Id == _userId || _following.Contains(user.Id);