From f1f30635b2d3ba9e581239a593077ee2c50fa6c2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 19 Jun 2022 01:55:45 +0200 Subject: [PATCH] hide deleted posts and comments from userpages (frequently requested) --- files/classes/user.py | 5 ++++- files/routes/posts.py | 2 ++ files/routes/users.py | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index bc295028d..23f6a33a4 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -299,7 +299,10 @@ class User(Base): posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False) if not (v and (v.admin_level > 1 or v.id == self.id)): - posts = posts.filter_by(deleted_utc=0, is_banned=False, private=False, ghost=False) + posts = posts.filter_by(is_banned=False, private=False, ghost=False) + + if not (v and v.admin_level > 1): + posts = posts.filter_by(deleted_utc=0) now = int(time.time()) if t == 'hour': diff --git a/files/routes/posts.py b/files/routes/posts.py index e9d916b3b..f646770f8 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1298,6 +1298,7 @@ def delete_post_pid(pid, v): g.db.add(post) cache.delete_memoized(frontlist) + cache.delete_memoized(User.userpagelisting) g.db.commit() @@ -1314,6 +1315,7 @@ def undelete_post_pid(pid, v): g.db.add(post) cache.delete_memoized(frontlist) + cache.delete_memoized(User.userpagelisting) g.db.commit() diff --git a/files/routes/users.py b/files/routes/users.py index 21b18501a..212f811ea 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1021,7 +1021,10 @@ def u_username_comments(username, v=None): comments = g.db.query(Comment.id).filter(Comment.author_id == u.id, Comment.parent_submission != None) if not v or (v.id != u.id and v.admin_level < 2): - comments = comments.filter(Comment.deleted_utc == 0, Comment.is_banned == False, Comment.ghost == False) + comments = comments.filter(Comment.is_banned == False, Comment.ghost == False) + + if not (v and v.admin_level > 1): + comments = comments.filter_by(deleted_utc=0) now = int(time.time()) if t == 'hour':