Make 'Anonymous Coward' configurable
Make the username that is displayed for users that haven't set a full name configurable. 'Anonymous Coward' that was hard-coded in Gerrit before was seen by some users as unprofessional and insulting. This is why for corporate environments it makes sense to configure another name. Signed-off-by: Edwin Kempin <edwin.kempin@sap.com> Change-Id: Ib2edee2af342b17df676e87cef99f92448895abe
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -26,8 +27,9 @@ public class AbandonedSender extends ReplyToChangeSender {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public AbandonedSender(EmailArguments ea, @Assisted Change c) {
|
||||
super(ea, c, "abandon");
|
||||
public AbandonedSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||
super(ea, anonymousCowardName, c, "abandon");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -26,9 +27,10 @@ public class AddReviewerSender extends NewChangeSender {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public AddReviewerSender(EmailArguments ea, SshInfo sshInfo,
|
||||
public AddReviewerSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, SshInfo sshInfo,
|
||||
@Assisted Change c) {
|
||||
super(ea, sshInfo, c);
|
||||
super(ea, anonymousCowardName, sshInfo, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -57,8 +57,9 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
||||
protected Set<Account.Id> authors;
|
||||
protected boolean emailOnlyAuthors;
|
||||
|
||||
protected ChangeEmail(EmailArguments ea, final Change c, final String mc) {
|
||||
super(ea, mc);
|
||||
protected ChangeEmail(EmailArguments ea, final String anonymousCowardName,
|
||||
final Change c, final String mc) {
|
||||
super(ea, anonymousCowardName, mc);
|
||||
change = c;
|
||||
changeData = change != null ? new ChangeData(change) : null;
|
||||
emailOnlyAuthors = false;
|
||||
|
@@ -17,6 +17,7 @@ package com.google.gerrit.server.mail;
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.reviewdb.Patch;
|
||||
import com.google.gerrit.reviewdb.PatchLineComment;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.patch.PatchFile;
|
||||
import com.google.gerrit.server.patch.PatchList;
|
||||
import com.google.inject.Inject;
|
||||
@@ -41,8 +42,9 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
private List<PatchLineComment> inlineComments = Collections.emptyList();
|
||||
|
||||
@Inject
|
||||
public CommentSender(EmailArguments ea, @Assisted Change c) {
|
||||
super(ea, c, "comment");
|
||||
public CommentSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||
super(ea, anonymousCowardName, c, "comment");
|
||||
}
|
||||
|
||||
public void setPatchLineComments(final List<PatchLineComment> plc) {
|
||||
|
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.AccountProjectWatch;
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.reviewdb.AccountProjectWatch.NotifyType;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
@@ -38,9 +39,10 @@ public class CreateChangeSender extends NewChangeSender {
|
||||
private final GroupCache groupCache;
|
||||
|
||||
@Inject
|
||||
public CreateChangeSender(EmailArguments ea, SshInfo sshInfo,
|
||||
public CreateChangeSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, SshInfo sshInfo,
|
||||
GroupCache groupCache, @Assisted Change c) {
|
||||
super(ea, sshInfo, c);
|
||||
super(ea, anonymousCowardName, sshInfo, c);
|
||||
this.groupCache = groupCache;
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import com.google.gerrit.common.data.ParameterizedString;
|
||||
import com.google.gerrit.reviewdb.Account;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -34,6 +35,7 @@ public class FromAddressGeneratorProvider implements
|
||||
|
||||
@Inject
|
||||
FromAddressGeneratorProvider(@GerritServerConfig final Config cfg,
|
||||
final @AnonymousCowardName String anonymousCowardName,
|
||||
@GerritPersonIdent final PersonIdent myIdent,
|
||||
final AccountCache accountCache) {
|
||||
|
||||
@@ -42,7 +44,9 @@ public class FromAddressGeneratorProvider implements
|
||||
|
||||
if (from == null || "MIXED".equalsIgnoreCase(from)) {
|
||||
ParameterizedString name = new ParameterizedString("${user} (Code Review)");
|
||||
generator = new PatternGen(srvAddr, accountCache, name, srvAddr.email);
|
||||
generator =
|
||||
new PatternGen(srvAddr, accountCache, anonymousCowardName, name,
|
||||
srvAddr.email);
|
||||
|
||||
} else if ("USER".equalsIgnoreCase(from)) {
|
||||
generator = new UserGen(accountCache, srvAddr);
|
||||
@@ -56,7 +60,9 @@ public class FromAddressGeneratorProvider implements
|
||||
if (name == null || name.getParameterNames().isEmpty()) {
|
||||
generator = new ServerGen(a);
|
||||
} else {
|
||||
generator = new PatternGen(srvAddr, accountCache, name, a.email);
|
||||
generator =
|
||||
new PatternGen(srvAddr, accountCache, anonymousCowardName, name,
|
||||
a.email);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,13 +124,16 @@ public class FromAddressGeneratorProvider implements
|
||||
private final String senderEmail;
|
||||
private final Address serverAddress;
|
||||
private final AccountCache accountCache;
|
||||
private final String anonymousCowardName;
|
||||
private final ParameterizedString namePattern;
|
||||
|
||||
PatternGen(final Address serverAddress, final AccountCache accountCache,
|
||||
final String anonymousCowardName,
|
||||
final ParameterizedString namePattern, final String senderEmail) {
|
||||
this.senderEmail = senderEmail;
|
||||
this.serverAddress = serverAddress;
|
||||
this.accountCache = accountCache;
|
||||
this.anonymousCowardName = anonymousCowardName;
|
||||
this.namePattern = namePattern;
|
||||
}
|
||||
|
||||
@@ -141,7 +150,7 @@ public class FromAddressGeneratorProvider implements
|
||||
final Account account = accountCache.get(fromId).getAccount();
|
||||
String fullName = account.getFullName();
|
||||
if (fullName == null || "".equals(fullName)) {
|
||||
fullName = "Anonymous Coward";
|
||||
fullName = anonymousCowardName;
|
||||
}
|
||||
senderName = namePattern.replace("user", fullName).toString();
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -25,8 +26,9 @@ public class MergeFailSender extends ReplyToChangeSender {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public MergeFailSender(EmailArguments ea, @Assisted Change c) {
|
||||
super(ea, c, "merge-failed");
|
||||
public MergeFailSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||
super(ea, anonymousCowardName, c, "merge-failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -23,6 +23,7 @@ import com.google.gerrit.reviewdb.ApprovalCategory;
|
||||
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.reviewdb.PatchSetApproval;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -39,8 +40,10 @@ public class MergedSender extends ReplyToChangeSender {
|
||||
private final ApprovalTypes approvalTypes;
|
||||
|
||||
@Inject
|
||||
public MergedSender(EmailArguments ea, ApprovalTypes at, @Assisted Change c) {
|
||||
super(ea, c, "merged");
|
||||
public MergedSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, ApprovalTypes at,
|
||||
@Assisted Change c) {
|
||||
super(ea, anonymousCowardName, c, "merged");
|
||||
approvalTypes = at;
|
||||
}
|
||||
|
||||
|
@@ -32,8 +32,9 @@ public abstract class NewChangeSender extends ChangeEmail {
|
||||
private final Set<Account.Id> reviewers = new HashSet<Account.Id>();
|
||||
private final Set<Account.Id> extraCC = new HashSet<Account.Id>();
|
||||
|
||||
protected NewChangeSender(EmailArguments ea, SshInfo sshInfo, Change c) {
|
||||
super(ea, c, "newchange");
|
||||
protected NewChangeSender(EmailArguments ea, String anonymousCowardName,
|
||||
SshInfo sshInfo, Change c) {
|
||||
super(ea, anonymousCowardName, c, "newchange");
|
||||
this.sshInfo = sshInfo;
|
||||
}
|
||||
|
||||
|
@@ -54,10 +54,14 @@ public abstract class OutgoingEmail {
|
||||
protected VelocityContext velocityContext;
|
||||
|
||||
protected final EmailArguments args;
|
||||
private final String anonymousCowardName;
|
||||
protected Account.Id fromId;
|
||||
|
||||
protected OutgoingEmail(EmailArguments ea, final String mc) {
|
||||
|
||||
protected OutgoingEmail(EmailArguments ea, final String anonymousCowardName,
|
||||
final String mc) {
|
||||
args = ea;
|
||||
this.anonymousCowardName = anonymousCowardName;
|
||||
messageClass = mc;
|
||||
headers = new LinkedHashMap<String, EmailHeader>();
|
||||
}
|
||||
@@ -226,7 +230,7 @@ public abstract class OutgoingEmail {
|
||||
/** Lookup a human readable name for an account, usually the "full name". */
|
||||
protected String getNameFor(final Account.Id accountId) {
|
||||
if (accountId == null) {
|
||||
return "Anonymous Coward";
|
||||
return anonymousCowardName;
|
||||
}
|
||||
|
||||
final Account userAccount = args.accountCache.get(accountId).getAccount();
|
||||
@@ -235,7 +239,7 @@ public abstract class OutgoingEmail {
|
||||
name = userAccount.getPreferredEmail();
|
||||
}
|
||||
if (name == null) {
|
||||
name = "Anonymous Coward #" + accountId;
|
||||
name = anonymousCowardName + " #" + accountId;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -254,7 +258,7 @@ public abstract class OutgoingEmail {
|
||||
return email;
|
||||
|
||||
} else /* (name == null && email == null) */{
|
||||
return "Anonymous Coward #" + accountId;
|
||||
return anonymousCowardName + " #" + accountId;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gwtjsonrpc.server.XsrfException;
|
||||
import com.google.inject.Inject;
|
||||
@@ -33,8 +34,9 @@ public class RegisterNewEmailSender extends OutgoingEmail {
|
||||
|
||||
@Inject
|
||||
public RegisterNewEmailSender(EmailArguments ea, AuthConfig ac,
|
||||
@AnonymousCowardName String anonymousCowardName,
|
||||
@Assisted final String address) {
|
||||
super(ea, "registernewemail");
|
||||
super(ea, anonymousCowardName, "registernewemail");
|
||||
authConfig = ac;
|
||||
addr = address;
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.reviewdb.Account;
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -39,8 +40,10 @@ public class ReplacePatchSetSender extends ReplyToChangeSender {
|
||||
private final SshInfo sshInfo;
|
||||
|
||||
@Inject
|
||||
public ReplacePatchSetSender(EmailArguments ea, SshInfo si, @Assisted Change c) {
|
||||
super(ea, c, "newpatchset");
|
||||
public ReplacePatchSetSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, SshInfo si,
|
||||
@Assisted Change c) {
|
||||
super(ea, anonymousCowardName, c, "newpatchset");
|
||||
sshInfo = si;
|
||||
}
|
||||
|
||||
|
@@ -22,8 +22,9 @@ public abstract class ReplyToChangeSender extends ChangeEmail {
|
||||
public T create(Change change);
|
||||
}
|
||||
|
||||
protected ReplyToChangeSender(EmailArguments ea, Change c, String mc) {
|
||||
super(ea, c, mc);
|
||||
protected ReplyToChangeSender(EmailArguments ea, String anonymousCowardName,
|
||||
Change c, String mc) {
|
||||
super(ea, anonymousCowardName, c, mc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -26,8 +27,9 @@ public class RestoredSender extends ReplyToChangeSender {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public RestoredSender(EmailArguments ea, @Assisted Change c) {
|
||||
super(ea, c, "restore");
|
||||
public RestoredSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||
super(ea, anonymousCowardName, c, "restore");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -25,8 +26,9 @@ public class RevertedSender extends ReplyToChangeSender {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public RevertedSender(EmailArguments ea, @Assisted Change c) {
|
||||
super(ea, c, "revert");
|
||||
public RevertedSender(EmailArguments ea,
|
||||
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||
super(ea, anonymousCowardName, c, "revert");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user