Merge "Add attention-set email footer"
This commit is contained in:
@@ -18,6 +18,7 @@ package com.google.gerrit.mail;
|
|||||||
public enum MailHeader {
|
public enum MailHeader {
|
||||||
// Gerrit metadata holders
|
// Gerrit metadata holders
|
||||||
ASSIGNEE("Gerrit-Assignee"),
|
ASSIGNEE("Gerrit-Assignee"),
|
||||||
|
ATTENTION("Gerrit-Attention"),
|
||||||
BRANCH("Gerrit-Branch"),
|
BRANCH("Gerrit-Branch"),
|
||||||
CC("Gerrit-CC"),
|
CC("Gerrit-CC"),
|
||||||
COMMENT_IN_REPLY_TO("Comment-In-Reply-To"),
|
COMMENT_IN_REPLY_TO("Comment-In-Reply-To"),
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
|
import static com.google.gerrit.server.util.AttentionSetUtil.additionsOnly;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -484,6 +487,9 @@ public abstract class ChangeEmail extends NotificationEmail {
|
|||||||
for (String reviewer : getEmailsByState(ReviewerStateInternal.CC)) {
|
for (String reviewer : getEmailsByState(ReviewerStateInternal.CC)) {
|
||||||
footers.add(MailHeader.CC.withDelimiter() + reviewer);
|
footers.add(MailHeader.CC.withDelimiter() + reviewer);
|
||||||
}
|
}
|
||||||
|
for (String attentionSet : getAttentionSet()) {
|
||||||
|
footers.add(MailHeader.ATTENTION.withDelimiter() + attentionSet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -509,6 +515,19 @@ public abstract class ChangeEmail extends NotificationEmail {
|
|||||||
return reviewers;
|
return reviewers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Set<String> getAttentionSet() {
|
||||||
|
Set<String> attentionSet = new TreeSet<>();
|
||||||
|
try {
|
||||||
|
attentionSet =
|
||||||
|
additionsOnly(changeData.attentionSet()).stream()
|
||||||
|
.map(a -> getNameEmailFor(a.account()))
|
||||||
|
.collect(toImmutableSet());
|
||||||
|
} catch (StorageException e) {
|
||||||
|
logger.atWarning().withCause(e).log("Cannot get change attention set");
|
||||||
|
}
|
||||||
|
return attentionSet;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getIncludeDiff() {
|
public boolean getIncludeDiff() {
|
||||||
return args.settings.includeDiff;
|
return args.settings.includeDiff;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1355,6 +1355,30 @@ public class AttentionSetIT extends AbstractDaemonTest {
|
|||||||
assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer was added");
|
assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer was added");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void attentionSetEmailFooter() throws Exception {
|
||||||
|
PushOneCommit.Result r = createChange();
|
||||||
|
|
||||||
|
// Add user to attention set. They receive an email with the attention footer.
|
||||||
|
change(r).addReviewer(user.id().toString());
|
||||||
|
assertThat(Iterables.getOnlyElement(sender.getMessages()).body())
|
||||||
|
.contains("Gerrit-Attention: " + user.fullName());
|
||||||
|
sender.clear();
|
||||||
|
|
||||||
|
// Irrelevant reply, User is still in the attention set.
|
||||||
|
change(r).current().review(ReviewInput.approve());
|
||||||
|
assertThat(Iterables.getOnlyElement(sender.getMessages()).body())
|
||||||
|
.contains("Gerrit-Attention: " + user.fullName());
|
||||||
|
sender.clear();
|
||||||
|
|
||||||
|
// Abandon the change which removes user from attention set; there is an email but without the
|
||||||
|
// attention footer.
|
||||||
|
change(r).abandon();
|
||||||
|
assertThat(Iterables.getOnlyElement(sender.getMessages()).body())
|
||||||
|
.doesNotContain("Gerrit-Attention: " + user.fullName());
|
||||||
|
sender.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private List<AttentionSetUpdate> getAttentionSetUpdatesForUser(
|
private List<AttentionSetUpdate> getAttentionSetUpdatesForUser(
|
||||||
PushOneCommit.Result r, TestAccount account) {
|
PushOneCommit.Result r, TestAccount account) {
|
||||||
return getAttentionSetUpdates(r.getChange().getId()).stream()
|
return getAttentionSetUpdates(r.getChange().getId()).stream()
|
||||||
|
|||||||
@@ -493,6 +493,15 @@ export const htmlTemplate = html`
|
|||||||
</code>
|
</code>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Changes requesting my attention</td>
|
||||||
|
<td>
|
||||||
|
<code class="queryExample">
|
||||||
|
"Gerrit-Attention: <em>Your Name</em>
|
||||||
|
<<em>your.email@example.com</em>>"
|
||||||
|
</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Changes from a specific owner</td>
|
<td>Changes from a specific owner</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user