invisibleify completely removed trees only (fixes #431) (#535)

* 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:
justcool393 2023-04-03 02:30:46 -07:00 committed by GitHub
parent 77af24a5b1
commit 39ce6a4ee9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 167 additions and 62 deletions

View file

@ -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: