From 9abd2cc508cdf48b7ff532ec6f04c66d3bdff812 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 8 Jul 2022 20:27:42 +0200 Subject: [PATCH] dont show deleted and removed posts in /notifications/posts --- files/classes/user.py | 2 +- files/routes/notifications.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 22e3850e7..34c8fcb91 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -476,7 +476,7 @@ class User(Base): @property @lazy def post_notifications_count(self): - return g.db.query(Submission).filter(Submission.author_id.in_(self.following_ids), Submission.created_utc > self.last_viewed_post_notifs).count() + return g.db.query(Submission).filter(Submission.author_id.in_(self.following_ids), Submission.created_utc > self.last_viewed_post_notifs, Submission.deleted_utc == 0, Submission.is_banned == False).count() @property @lazy diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 5c9e0f723..8cd45dd9a 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -88,7 +88,11 @@ def notifications_posts(v): try: page = max(int(request.values.get("page", 1)), 1) except: page = 1 - listing = g.db.query(Submission).filter(Submission.author_id.in_(v.following_ids)).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all() + listing = g.db.query(Submission.id).filter( + Submission.author_id.in_(v.following_ids), + Submission.deleted_utc == 0, + Submission.is_banned == False + ).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all() next_exists = (len(listing) > 25) listing = listing[:25]