dont show deleted and removed posts in /notifications/posts

master
Aevann1 2022-07-08 20:27:42 +02:00
parent ea3d7997c8
commit 9abd2cc508
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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]