Aevann1 2022-12-07 11:20:06 +02:00
parent e8f9d39bcf
commit 98afb45b7e
5 changed files with 19 additions and 14 deletions

View File

@ -79,7 +79,6 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
else: template = "submission.html"
return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr)
#- API
@app.post("/comment")
@limiter.limit("1/second;20/minute;200/hour;1000/day")
@auth_required
@ -311,7 +310,7 @@ def comment(v):
v.comment_count = g.db.query(Comment).filter(
Comment.author_id == v.id,
Comment.parent_submission != None,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
Comment.deleted_utc == 0
).count()
g.db.add(v)
@ -346,7 +345,6 @@ def comment(v):
return {"comment": render_template("comments.html", v=v, comments=[c])}
#- API
@app.post("/wall_comment")
@limiter.limit("1/second;20/minute;200/hour;1000/day")
@auth_required
@ -523,7 +521,7 @@ def wall_comment(v):
v.comment_count = g.db.query(Comment).filter(
Comment.author_id == v.id,
Comment.parent_submission != None,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
Comment.deleted_utc == 0
).count()
g.db.add(v)
@ -550,6 +548,8 @@ def wall_comment(v):
g.db.flush()
cache.delete_memoized(comment_idlist)
if v.client: return c.json(db=g.db)
return {"comment": render_template("comments.html", v=v, comments=[c])}
@ -644,7 +644,7 @@ def delete_comment(cid, v):
g.db.flush()
v.comment_count = g.db.query(Comment).filter(
Comment.author_id == v.id,
Comment.parent_submission != None,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
Comment.deleted_utc == 0
).count()
g.db.add(v)
@ -664,7 +664,7 @@ def undelete_comment(cid, v):
g.db.flush()
v.comment_count = g.db.query(Comment).filter(
Comment.author_id == v.id,
Comment.parent_submission != None,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
Comment.deleted_utc == 0
).count()
g.db.add(v)

View File

@ -210,8 +210,10 @@ def all_comments(v:User):
@cache.memoize(timeout=86400)
def comment_idlist(v=None, page=1, sort="new", t="all", gt=0, lt=0, site=None):
comments = g.db.query(Comment.id) \
.join(Comment.post) \
.filter(Comment.parent_submission != None)
.outerjoin(Comment.post) \
.filter(
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
)
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
comments = comments.filter(

View File

@ -181,8 +181,11 @@ def searchcomments(v:User):
criteria = searchparse(query)
comments = g.db.query(Comment.id).join(Comment.post) \
.filter(Comment.parent_submission != None, Comment.author_id.notin_(v.userblocks))
comments = g.db.query(Comment.id).outerjoin(Comment.post) \
.filter(
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
Comment.author_id.notin_(v.userblocks),
)
if 'post' in criteria:

View File

@ -938,11 +938,11 @@ def u_username_comments(username, v=None):
comment_post_author = aliased(User)
comments = g.db.query(Comment.id) \
.join(Comment.post) \
.join(comment_post_author, Submission.author) \
.outerjoin(Comment.post) \
.outerjoin(comment_post_author, Submission.author) \
.filter(
Comment.author_id == u.id,
Comment.parent_submission != None
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
)
if not v or (v.id != u.id and v.admin_level < PERMS['POST_COMMENT_MODERATION']):

View File

@ -93,7 +93,7 @@
{% elif c.author_id==AUTOJANNY_ID %}
<span class="font-weight-bold">Notification</span>
{% elif c.wall_user_id %}
{% if request.path == '/notifications' %}
{% if not wall %}
{% if c.wall_user_id == v.id %}
<span class="font-weight-bold"><a href="/@{{v.username}}">Your Profile Wall</a></span>
{% else %}