Move setListIdHeader() method to NotificationEmail class for reuse
Move setListIdHeader() and getListId() methods from ChangeEmail to base class NotificationEmail, so that they can be reused in sending direct push emails in a later change. Change-Id: Ia5ce648878db2ba33522323b13be9d61ee3d26c6
This commit is contained in:
@@ -157,23 +157,10 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
}
|
||||
setChangeSubjectHeader();
|
||||
setHeader("X-Gerrit-Change-Id", "" + change.getKey().get());
|
||||
setListIdHeader();
|
||||
setChangeUrlHeader();
|
||||
setCommitIdHeader();
|
||||
}
|
||||
|
||||
private void setListIdHeader() throws EmailException {
|
||||
// Set a reasonable list id so that filters can be used to sort messages
|
||||
setVHeader("List-Id", "<$email.listId.replace('@', '.')>");
|
||||
if (getSettingsUrl() != null) {
|
||||
setVHeader("List-Unsubscribe", "<$email.settingsUrl>");
|
||||
}
|
||||
}
|
||||
|
||||
public String getListId() throws EmailException {
|
||||
return velocify("gerrit-$projectName.replace('/', '-')@$email.gerritHost");
|
||||
}
|
||||
|
||||
private void setChangeUrlHeader() {
|
||||
final String u = getChangeUrl();
|
||||
if (u != null) {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -48,6 +49,24 @@ public abstract class NotificationEmail extends OutgoingEmail {
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() throws EmailException {
|
||||
super.init();
|
||||
setListIdHeader();
|
||||
}
|
||||
|
||||
private void setListIdHeader() throws EmailException {
|
||||
// Set a reasonable list id so that filters can be used to sort messages
|
||||
setVHeader("List-Id", "<$email.listId.replace('@', '.')>");
|
||||
if (getSettingsUrl() != null) {
|
||||
setVHeader("List-Unsubscribe", "<$email.settingsUrl>");
|
||||
}
|
||||
}
|
||||
|
||||
public String getListId() throws EmailException {
|
||||
return velocify("gerrit-$projectName.replace('/', '-')@$email.gerritHost");
|
||||
}
|
||||
|
||||
/** Include users and groups that want notification of events. */
|
||||
protected void includeWatchers(NotifyType type) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user