From 84f4fc164d215cc27f07e73eafd3c70cc69552cf Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 4 Aug 2022 22:54:24 +0200 Subject: [PATCH] make chud editting less annoying --- files/routes/comments.py | 34 ++-------------------------------- files/routes/posts.py | 32 ++------------------------------ 2 files changed, 4 insertions(+), 62 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 6f33b2cc7..001aad93a 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -737,38 +737,8 @@ def edit_comment(cid, v): notif = Notification(comment_id=c.id, user_id=AEVANN_ID) g.db.add(notif) - if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower() and not c.is_banned: - - c.is_banned = True - c.ban_reason = "AutoJanny" - - g.db.add(c) - - - body = AGENDAPOSTER_MSG.format(username=v.username, type='comment', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) - - body_jannied_html = AGENDAPOSTER_MSG_HTML.format(id=v.id, username=v.username, type='comment', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) - - - - c_jannied = Comment(author_id=AUTOJANNY_ID, - parent_submission=c.parent_submission, - distinguish_level=6, - parent_comment_id=c.id, - level=c.level+1, - is_bot=True, - body=body, - body_html=body_jannied_html, - top_comment_id=c.top_comment_id, - ghost=c.ghost - ) - - g.db.add(c_jannied) - g.db.flush() - - n = Notification(comment_id=c_jannied.id, user_id=v.id) - g.db.add(n) - + if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower(): + return {"error": f"You forgot to include {AGENDAPOSTER_PHRASE} in your comment!"}, 403 if int(time.time()) - c.created_utc > 60 * 3: c.edited_utc = int(time.time()) diff --git a/files/routes/posts.py b/files/routes/posts.py index fc2d61299..ce56f701d 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -450,37 +450,9 @@ def edit_post(pid, v): p.body_html = body_html - if v.id == p.author_id and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in f'{p.body}{p.title}'.lower() and not p.is_banned: + if v.id == p.author_id and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in f'{p.body}{p.title}'.lower(): + return {"error": f"You forgot to include {AGENDAPOSTER_PHRASE} in your post!"}, 403 - p.is_banned = True - p.ban_reason = "AutoJanny" - - g.db.add(p) - - body = AGENDAPOSTER_MSG.format(username=v.username, type='post', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) - - body_jannied_html = AGENDAPOSTER_MSG_HTML.format(id=v.id, username=v.username, type='post', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) - - c_jannied = Comment(author_id=AUTOJANNY_ID, - parent_submission=p.id, - level=1, - over_18=False, - is_bot=True, - app_id=None, - stickied='AutoJanny', - distinguish_level=6, - body=body, - body_html=body_jannied_html, - ghost=p.ghost - ) - - g.db.add(c_jannied) - g.db.flush() - - c_jannied.top_comment_id = c_jannied.id - - n = Notification(comment_id=c_jannied.id, user_id=v.id) - g.db.add(n) if not p.private and not p.ghost: notify_users = NOTIFY_USERS(f'{p.title} {p.body}', v)