diff options
Diffstat (limited to 'gerrit-server/src/main/java/com/google/gerrit/server/mail/CommentSender.java')
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/mail/CommentSender.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/CommentSender.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/CommentSender.java index e7cc1ff86b..b16ab2a595 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/CommentSender.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/CommentSender.java @@ -14,11 +14,12 @@ package com.google.gerrit.server.mail; +import com.google.gerrit.common.errors.EmailException; +import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Patch; import com.google.gerrit.reviewdb.client.PatchLineComment; -import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType; -import com.google.gerrit.server.config.AnonymousCowardName; +import com.google.gerrit.server.change.PostReview.NotifyHandling; import com.google.gerrit.server.patch.PatchFile; import com.google.gerrit.server.patch.PatchList; import com.google.gerrit.server.patch.PatchListNotAvailableException; @@ -37,15 +38,18 @@ import java.util.Set; /** Send comments, after the author of them hit used Publish Comments in the UI. */ public class CommentSender extends ReplyToChangeSender { public static interface Factory { - public CommentSender create(Change change); + public CommentSender create(NotifyHandling notify, Change change); } + private final NotifyHandling notify; private List<PatchLineComment> inlineComments = Collections.emptyList(); @Inject public CommentSender(EmailArguments ea, - @AnonymousCowardName String anonymousCowardName, @Assisted Change c) { - super(ea, anonymousCowardName, c, "comment"); + @Assisted NotifyHandling notify, + @Assisted Change c) { + super(ea, c, "comment"); + this.notify = notify; } public void setPatchLineComments(final List<PatchLineComment> plc) { @@ -67,9 +71,13 @@ public class CommentSender extends ReplyToChangeSender { protected void init() throws EmailException { super.init(); - ccAllApprovals(); - bccStarredBy(); - bccWatches(NotifyType.ALL_COMMENTS); + if (notify.compareTo(NotifyHandling.OWNER_REVIEWERS) >= 0) { + ccAllApprovals(); + } + if (notify.compareTo(NotifyHandling.ALL) >= 0) { + bccStarredBy(); + includeWatchers(NotifyType.ALL_COMMENTS); + } } @Override @@ -77,6 +85,15 @@ public class CommentSender extends ReplyToChangeSender { appendText(velocifyFile("Comment.vm")); } + @Override + public void formatFooter() throws EmailException { + appendText(velocifyFile("CommentFooter.vm")); + } + + public boolean hasInlineComments() { + return !inlineComments.isEmpty(); + } + public String getInlineComments() { return getInlineComments(1); } |