[backend/masto-client] Don't deliver push notifications from blocked or muted notifiers (ISH-273)

This commit is contained in:
Laura Hausmann 2024-04-27 01:47:16 +02:00
parent b9fa870054
commit bc1e695193
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -47,6 +47,17 @@ public class PushService(
if (subscriptions.Count == 0)
return;
var skip = await db.Blockings.AnyAsync(p => p.Blocker == notification.Notifiee &&
p.Blockee == notification.Notifier) ||
await db.Mutings.AnyAsync(p => p.Muter == notification.Notifiee &&
p.Mutee == notification.Notifier);
if (skip)
{
// Notifier is blocked or muted, so we shouldn't deliver the notification
return;
}
logger.LogDebug("Delivering mastodon push notification {id} for user {userId}", notification.Id,
notification.Notifiee.Id);