From 5b4ccc9ed6726e1b894c8e1306dc1a7440bf561b Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Wed, 9 Mar 2016 14:19:13 -0700 Subject: [PATCH] AutoMod: ensure comment on a post sends orangered Normally, if a moderator leaves a top-level comment on a post and distinguishes it, we send an orangered to the author of the post even if they have "send replies to my inbox" disabled for that post. This is done since a distinguished top-level comment is often used to give important information to the author (such as why the post was removed). However, since AutoMod distinguishes its comments "directly" by just setting the attribute, this logic wasn't being checked for its comments, and it hasn't been sending orangereds in cases where it should be. This commit fixes that, and ensures that it'll always send one whenever it's commenting on a post. --- r2/r2/lib/automoderator.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/r2/r2/lib/automoderator.py b/r2/r2/lib/automoderator.py index 42d2f3c1f..a7e6513ef 100644 --- a/r2/r2/lib/automoderator.py +++ b/r2/r2/lib/automoderator.py @@ -66,6 +66,7 @@ from r2.models import ( Comment, DeletedUser, Frontpage, + Inbox, LastModified, Link, Message, @@ -1432,6 +1433,14 @@ class Rule(object): new_comment.distinguished = "yes" new_comment.sendreplies = False new_comment._commit() + + # If the comment isn't going to be put into the user's inbox + # due to them having sendreplies disabled, force it. For a normal + # mod, distinguishing the comment would do this, but it doesn't + # happen here since we're setting .distinguished directly. + if isinstance(item, Link) and not inbox_rel: + inbox_rel = Inbox._add(data["author"], new_comment, "selfreply") + queries.new_comment(new_comment, inbox_rel) if self.comment_stickied: