From 62fcaec40d9c1c3bd337998abeebb1772de6204c Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 19 Mar 2023 10:29:58 +0200 Subject: [PATCH] fix muted users not notifying the person they reply to --- files/classes/user.py | 6 +++++- files/routes/notifications.py | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index bc4820e5a..5eda4fee0 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -625,9 +625,13 @@ class User(Base): .filter( Notification.read == False, Notification.user_id == self.id, - not_(and_(Comment.sentto == MODMAIL_ID, User.is_muted)), )) + if self.admin_level >= PERMS['VIEW_MODMAIL']: + notifs = notifs.filter( + not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted)) + ) + if not self.can_see_shadowbanned: notifs = notifs.filter( User.shadowbanned == None, diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 3b24e0b32..e8caa9bf6 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -301,12 +301,16 @@ def notifications(v:User): n.read = True g.db.add(n) - comments = g.db.query(Comment, Notification).join(Notification.comment).join(Comment.author).filter( + comments = g.db.query(Comment, Notification).join(Notification.comment).filter( Notification.user_id == v.id, or_(Comment.sentto == None, Comment.sentto != v.id), - not_(and_(Comment.sentto == MODMAIL_ID, User.is_muted)), ) + if v.admin_level >= PERMS['VIEW_MODMAIL']: + comments = comments.join(Comment.author).filter( + not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted)) + ) + if v.admin_level < PERMS['USER_SHADOWBAN']: comments = comments.filter( Comment.is_banned == False,