Allow sending emails as 'Gerrit Code Review'
Use 'Gerrit Code Review' as from-name when no account ID is provided for an outgoing email. 'Anonymous Coward' should only be used if an account ID is provided, but the account does neither have a full name nor a preferred email address. Change-Id: I8277533acc3a27d45628849b9e9525ee5efcd262 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
parent
c04555d3e2
commit
64d33627b4
|
@ -19,6 +19,7 @@ import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.AnonymousUser;
|
import com.google.gerrit.server.AnonymousUser;
|
||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
|
import com.google.gerrit.server.GerritPersonIdentProvider;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.IdentifiedUser.GenericFactory;
|
import com.google.gerrit.server.IdentifiedUser.GenericFactory;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
|
@ -41,6 +42,7 @@ import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
import org.apache.velocity.runtime.RuntimeInstance;
|
import org.apache.velocity.runtime.RuntimeInstance;
|
||||||
|
import org.eclipse.jgit.lib.PersonIdent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -60,6 +62,7 @@ public class EmailArguments {
|
||||||
final ChangeNotes.Factory changeNotesFactory;
|
final ChangeNotes.Factory changeNotesFactory;
|
||||||
final AnonymousUser anonymousUser;
|
final AnonymousUser anonymousUser;
|
||||||
final String anonymousCowardName;
|
final String anonymousCowardName;
|
||||||
|
final PersonIdent gerritPersonIdent;
|
||||||
final Provider<String> urlProvider;
|
final Provider<String> urlProvider;
|
||||||
final AllProjectsName allProjectsName;
|
final AllProjectsName allProjectsName;
|
||||||
final List<String> sshAddresses;
|
final List<String> sshAddresses;
|
||||||
|
@ -84,6 +87,7 @@ public class EmailArguments {
|
||||||
ChangeNotes.Factory changeNotesFactory,
|
ChangeNotes.Factory changeNotesFactory,
|
||||||
AnonymousUser anonymousUser,
|
AnonymousUser anonymousUser,
|
||||||
@AnonymousCowardName String anonymousCowardName,
|
@AnonymousCowardName String anonymousCowardName,
|
||||||
|
GerritPersonIdentProvider gerritPersonIdentProvider,
|
||||||
@CanonicalWebUrl @Nullable Provider<String> urlProvider,
|
@CanonicalWebUrl @Nullable Provider<String> urlProvider,
|
||||||
AllProjectsName allProjectsName,
|
AllProjectsName allProjectsName,
|
||||||
ChangeQueryBuilder queryBuilder,
|
ChangeQueryBuilder queryBuilder,
|
||||||
|
@ -108,6 +112,7 @@ public class EmailArguments {
|
||||||
this.changeNotesFactory = changeNotesFactory;
|
this.changeNotesFactory = changeNotesFactory;
|
||||||
this.anonymousUser = anonymousUser;
|
this.anonymousUser = anonymousUser;
|
||||||
this.anonymousCowardName = anonymousCowardName;
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
|
this.gerritPersonIdent = gerritPersonIdentProvider.get();
|
||||||
this.urlProvider = urlProvider;
|
this.urlProvider = urlProvider;
|
||||||
this.allProjectsName = allProjectsName;
|
this.allProjectsName = allProjectsName;
|
||||||
this.queryBuilder = queryBuilder;
|
this.queryBuilder = queryBuilder;
|
||||||
|
|
|
@ -254,7 +254,7 @@ public abstract class OutgoingEmail {
|
||||||
/** Lookup a human readable name for an account, usually the "full name". */
|
/** Lookup a human readable name for an account, usually the "full name". */
|
||||||
protected String getNameFor(final Account.Id accountId) {
|
protected String getNameFor(final Account.Id accountId) {
|
||||||
if (accountId == null) {
|
if (accountId == null) {
|
||||||
return args.anonymousCowardName;
|
return args.gerritPersonIdent.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Account userAccount = args.accountCache.get(accountId).getAccount();
|
final Account userAccount = args.accountCache.get(accountId).getAccount();
|
||||||
|
|
Loading…
Reference in New Issue