sfdfsd
This commit is contained in:
parent
f30c9c3ce5
commit
0e03dbe9ff
2 changed files with 20 additions and 11 deletions
|
@ -216,7 +216,7 @@ def get_comment(i, v=None, graceful=False):
|
||||||
return comment
|
return comment
|
||||||
|
|
||||||
|
|
||||||
def get_comments(cids, v=None, load_parent=False):
|
def get_comments(cids, v=None, load_parent=False, shadowbanned=False):
|
||||||
|
|
||||||
if not cids: return []
|
if not cids: return []
|
||||||
|
|
||||||
|
@ -235,8 +235,8 @@ def get_comments(cids, v=None, load_parent=False):
|
||||||
blocking.c.id,
|
blocking.c.id,
|
||||||
blocked.c.id,
|
blocked.c.id,
|
||||||
).filter(Comment.id.in_(cids))
|
).filter(Comment.id.in_(cids))
|
||||||
|
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
|
if not shadowbanned and not v.shadowbanned and v.admin_level < 2:
|
||||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments = comments.join(
|
comments = comments.join(
|
||||||
|
|
|
@ -367,7 +367,7 @@ def random_post(v):
|
||||||
return redirect(f"/post/{post.id}")
|
return redirect(f"/post/{post.id}")
|
||||||
|
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"):
|
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", shadowbanned=False):
|
||||||
|
|
||||||
posts = g.db.query(Submission)
|
posts = g.db.query(Submission)
|
||||||
cc_idlist = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()]
|
cc_idlist = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()]
|
||||||
|
@ -415,6 +415,7 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"):
|
||||||
elif sort == "bottom":
|
elif sort == "bottom":
|
||||||
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
||||||
|
|
||||||
|
if shadowbanned: comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned != None)
|
||||||
comments = comments.offset(25 * (page - 1)).limit(26).all()
|
comments = comments.offset(25 * (page - 1)).limit(26).all()
|
||||||
return [x[0] for x in comments]
|
return [x[0] for x in comments]
|
||||||
|
|
||||||
|
@ -428,13 +429,21 @@ def all_comments(v):
|
||||||
sort=request.values.get("sort", "new")
|
sort=request.values.get("sort", "new")
|
||||||
t=request.values.get("t", defaulttimefilter)
|
t=request.values.get("t", defaulttimefilter)
|
||||||
|
|
||||||
idlist = comment_idlist(v=v,
|
if request.values.get("shadowbanned"):
|
||||||
page=page,
|
idlist = comment_idlist(v=v,
|
||||||
sort=sort,
|
page=page,
|
||||||
t=t,
|
sort=sort,
|
||||||
)
|
t=t,
|
||||||
|
shadowbanned=true
|
||||||
comments = get_comments(idlist, v=v)
|
)
|
||||||
|
comments = get_comments(idlist, v=v, shadowbanned=True)
|
||||||
|
else:
|
||||||
|
idlist = comment_idlist(v=v,
|
||||||
|
page=page,
|
||||||
|
sort=sort,
|
||||||
|
t=t,
|
||||||
|
)
|
||||||
|
comments = get_comments(idlist, v=v)
|
||||||
|
|
||||||
next_exists = len(idlist) > 25
|
next_exists = len(idlist) > 25
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue