diff --git a/files/classes/user.py b/files/classes/user.py index 402c992cd..2391c8026 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -784,17 +784,19 @@ class User(Base): @lazy def post_notifications_count(self): return g.db.query(Post).filter( - or_( - Post.author_id.in_(self.followed_users), - Post.sub.in_(self.followed_subs) - ), Post.created_utc > self.last_viewed_post_notifs, + or_( + Post.sub.in_(self.followed_subs), + and_( + Post.author_id.in_(self.followed_users), + Post.notify == True, + Post.ghost == False, + ), + ), Post.deleted_utc == 0, Post.is_banned == False, Post.private == False, - Post.notify == True, Post.author_id != self.id, - Post.ghost == False, Post.author_id.notin_(self.userblocks), or_(Post.sub == None, Post.sub.notin_(self.sub_blocks)), ).count() diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 1eee22bcf..b9f32bec7 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -166,15 +166,17 @@ def notifications_posts(v): listing = g.db.query(Post).filter( or_( - Post.author_id.in_(v.followed_users), - Post.sub.in_(v.followed_subs) + Post.sub.in_(v.followed_subs), + and_( + Post.author_id.in_(v.followed_users), + Post.notify == True, + Post.ghost == False, + ), ), Post.deleted_utc == 0, Post.is_banned == False, Post.private == False, - Post.notify == True, Post.author_id != v.id, - Post.ghost == False, Post.author_id.notin_(v.userblocks), or_(Post.sub == None, Post.sub.notin_(v.sub_blocks)), ).options(load_only(Post.id))