forked from rDrama/rDrama
Fix reply/mention notifications from muted users.
Consider the case of the current /notifications filter condition: WHERE ... NOT ((comments.sentto = 2) AND (users.is_muted)) SELECT 1 WHERE NOT ((null = 2) AND (true)); ⇒ 0 rows SELECT 1 WHERE NOT ((1 = 2) AND (true)); ⇒ 1 row SELECT 1 WHERE NOT ((2 = 2) AND (true)); ⇒ 0 rows We want the first expression, where comments.sentto = null, to evaluate to false, not to null, so it negates to true. Behavior as written is: SELECT 1 WHERE NOT ((null = 2) AND (true)); → SELECT 1 WHERE NOT (null AND true); → SELECT 1 WHERE NOT null; → SELECT 1 WHERE null; Which guarantees a null return set. If we check first for non-nullity: SELECT 1 WHERE NOT ((null IS NOT null) AND (null = 2) AND (true)); ⇒ 1 SELECT 1 WHERE NOT ((1 IS NOT null) AND (1 = 2) AND (true)); ⇒ 1 SELECT 1 WHERE NOT ((2 IS NOT null) AND (2 = 2) AND (true)); ⇒ 0master
parent
190490a734
commit
9eab252e5b
|
@ -591,7 +591,7 @@ class User(Base):
|
|||
Notification.user_id == self.id,
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
not_(and_(Comment.sentto == MODMAIL_ID, User.is_muted)),
|
||||
not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted)),
|
||||
))
|
||||
|
||||
if not self.can_see_shadowbanned:
|
||||
|
|
|
@ -273,7 +273,7 @@ def notifications(v):
|
|||
Comment.deleted_utc == 0,
|
||||
Comment.body_html.notlike('%<p>New site mention%<a href="https://old.reddit.com/r/%'),
|
||||
or_(Comment.sentto == None, Comment.sentto == MODMAIL_ID),
|
||||
not_(and_(Comment.sentto == MODMAIL_ID, User.is_muted)),
|
||||
not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted)),
|
||||
)
|
||||
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
|
|
Loading…
Reference in New Issue