From 3bf62c6ff04dba5a68bbee528cddb9badcc08287 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 2 Oct 2022 13:31:02 +0200 Subject: [PATCH] add missing ban_reason when shadowbanning --- files/routes/chat.py | 1 + files/routes/comments.py | 2 ++ files/routes/login.py | 2 ++ files/routes/posts.py | 2 ++ files/routes/reporting.py | 2 ++ files/routes/users.py | 2 ++ 6 files changed, 11 insertions(+) diff --git a/files/routes/chat.py b/files/routes/chat.py index 5dd9752031..f26f32ab83 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -83,6 +83,7 @@ def speak(data, v): elif blackjack and any(i in text.lower() for i in blackjack.split()): emit('speak', data) v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' g.db.add(v) send_repeatable_notification(CARP_ID, f"{v.username} has been shadowbanned because of a chat message.") elif recipient: diff --git a/files/routes/comments.py b/files/routes/comments.py index dfa0b359f2..3fc5952da2 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -327,6 +327,7 @@ def comment(v): if blackjack and any(i in c.body.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' notif = Notification(comment_id=c.id, user_id=CARP_ID) g.db.add(notif) @@ -692,6 +693,7 @@ def edit_comment(cid, v): if blackjack and any(i in c.body.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' g.db.add(v) notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=CARP_ID).one_or_none() if not notif: diff --git a/files/routes/login.py b/files/routes/login.py index dfb7a4005c..65b99b8ef0 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -86,9 +86,11 @@ def check_for_alts(current): for u in current.alts_unique: if u.shadowbanned: current.shadowbanned = u.shadowbanned + if not current.is_banned: current.ban_reason = u.ban_reason g.db.add(current) elif current.shadowbanned: u.shadowbanned = current.shadowbanned + if not u.is_banned: u.ban_reason = current.ban_reason g.db.add(u) diff --git a/files/routes/posts.py b/files/routes/posts.py index e5bfec1cad..57058d3d2b 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -437,6 +437,7 @@ def edit_post(pid, v): if blackjack and any(i in f'{p.body} {p.title} {p.url}'.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' g.db.add(v) send_repeatable_notification(CARP_ID, p.permalink) @@ -919,6 +920,7 @@ def submit_post(v, sub=None): if blackjack and any(i in f'{post.body} {post.title} {post.url}'.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' g.db.add(v) send_repeatable_notification(CARP_ID, post.permalink) diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 7c7a1db61c..4b965faf09 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -18,6 +18,7 @@ def flag_post(pid, v): if blackjack and any(i in reason.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' send_repeatable_notification(CARP_ID, f"reports on {post.permalink}") if v.is_muted: @@ -127,6 +128,7 @@ def flag_comment(cid, v): if blackjack and any(i in reason.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' send_repeatable_notification(CARP_ID, f"reports on {comment.permalink}") reason = reason[:100] diff --git a/files/routes/users.py b/files/routes/users.py index fd2cbb29f5..54aa674ab8 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -772,6 +772,7 @@ def message2(v, username): if blackjack and any(i in c.body_html.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' g.db.add(v) notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=CARP_ID).one_or_none() if not notif: @@ -847,6 +848,7 @@ def messagereply(v): if blackjack and any(i in c.body_html.lower() for i in blackjack.split()): v.shadowbanned = 'AutoJanny' + if not v.is_banned: v.ban_reason = 'Blackjack' g.db.add(v) notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=CARP_ID).one_or_none() if not notif: