[backend/streaming] Enforce notification blocks/mutes in StreamingConnectionAggregate

This commit is contained in:
Laura Hausmann 2024-05-06 23:19:56 +02:00
parent b97c21a87b
commit 32a4875162
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -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<NotificationRenderer>();
@ -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);