From 69f1b09a766866dc7d189b35416617c8b82c28d0 Mon Sep 17 00:00:00 2001 From: TLSM Date: Mon, 10 Oct 2022 23:40:08 -0400 Subject: [PATCH] Restrict editing old posts (harmonize comments). --- files/routes/posts.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/files/routes/posts.py b/files/routes/posts.py index b276f6030..953dae12c 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -411,6 +411,11 @@ def edit_post(pid, v): if v.id != p.author_id and v.admin_level < PERMS['POST_EDITING']: abort(403) + # Disable edits on things older than 1wk unless it's a draft or editor is a jannie + if (time.time() - p.created_utc > 7*24*60*60 and not p.private + and not v.admin_level >= PERMS['POST_EDITING']): + return {"error": "You can't edit posts older than 1 week!"}, 403 + title = sanitize_raw_title(request.values.get("title", "")) body = sanitize_raw_body(request.values.get("body", ""), True)