* invisibleify completely removed trees only (fixes #431) * fix visibility state for shadowbanned users. this also ends up moving some of the complexity out of the templates. * comments: remove unused variable * moderation state machine * no seriously this really should check for v not being None * fix shadowban state * fix visibility state * update stateful counters * don't use bespoke function for show_descendants * properly mock ModerationState for cron submissions * fix approval discrepency * remove treenukes for removed comments * show shadowbans as removed
This commit is contained in:
parent
77af24a5b1
commit
39ce6a4ee9
9 changed files with 167 additions and 62 deletions
|
@ -331,17 +331,13 @@ def edit_comment(cid, v):
|
|||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@auth_required
|
||||
def delete_comment(cid, v):
|
||||
|
||||
c = get_comment(cid, v=v)
|
||||
|
||||
if not c.deleted_utc:
|
||||
|
||||
if c.author_id != v.id: abort(403)
|
||||
|
||||
c.deleted_utc = int(time.time())
|
||||
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
if c.deleted_utc: abort(409)
|
||||
if c.author_id != v.id: abort(403)
|
||||
c.deleted_utc = int(time.time())
|
||||
# TODO: update stateful counters
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
|
||||
return {"message": "Comment deleted!"}
|
||||
|
||||
|
@ -349,16 +345,13 @@ def delete_comment(cid, v):
|
|||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@auth_required
|
||||
def undelete_comment(cid, v):
|
||||
|
||||
c = get_comment(cid, v=v)
|
||||
|
||||
if c.deleted_utc:
|
||||
if c.author_id != v.id: abort(403)
|
||||
|
||||
c.deleted_utc = 0
|
||||
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
if not c.deleted_utc: abort(409)
|
||||
if c.author_id != v.id: abort(403)
|
||||
c.deleted_utc = 0
|
||||
# TODO: update stateful counters
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
|
||||
return {"message": "Comment undeleted!"}
|
||||
|
||||
|
@ -366,7 +359,6 @@ def undelete_comment(cid, v):
|
|||
@app.post("/pin_comment/<cid>")
|
||||
@auth_required
|
||||
def pin_comment(cid, v):
|
||||
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if not comment.is_pinned:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue