diff --git a/files/routes/comments.py b/files/routes/comments.py index 704cf8395..ac53c17b5 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -450,6 +450,16 @@ def delete_comment(cid, v): for sort in COMMENT_SORTS.keys(): cache.delete(f'post_{c.parent_post}_{sort}') + if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and c.parent_post == SNAPPY_THREAD and c.level == 1: + body = '\n{[para]}\n' + c.body + '\n' + with open(f"snappy_{SITE_NAME}.txt", "r", encoding="utf-8") as f: + old_text = f.read() + + if old_text.endswith(body): + new_text = old_text.split(body)[0] + '\n' + with open(f"snappy_{SITE_NAME}.txt", "w", encoding="utf-8") as f: + f.write(new_text) + return {"message": "Comment deleted!"} @app.post("/undelete/comment/")