stop shadowbanned content from taking up space in page while invisible

pull/221/head
Aevann 2024-01-12 09:15:58 +02:00
parent 5885f039f0
commit 660e90fc89
2 changed files with 9 additions and 0 deletions

View File

@ -134,6 +134,9 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
word = escape_for_search(word)
posts = posts.filter(not_(Post.title.ilike(f'%{word}%')))
if not v.can_see_shadowbanned:
posts = posts.join(Post.author).filter(or_(User.id == v.id, User.shadowbanned == None))
total = posts.count()
posts = sort_objects(sort, posts, Post)
@ -236,6 +239,9 @@ def comment_idlist(v=None, page=1, sort="new", t="day", gt=0, lt=0):
if not gt and not lt:
comments = apply_time_filter(t, comments, Comment)
if not v.can_see_shadowbanned:
comments = comments.join(Comment.author).filter(or_(User.id == v.id, User.shadowbanned == None))
total = comments.count()
comments = sort_objects(sort, comments, Comment)

View File

@ -853,6 +853,9 @@ def u_username_wall(v, username):
Comment.deleted_utc == 0
)
if not v.can_see_shadowbanned:
comments = comments.join(Comment.author).filter(or_(User.id == v.id, User.shadowbanned == None))
total = comments.count()
comments = comments.order_by(Comment.created_utc.desc()) \
.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()