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:
@@ -2068,6 +2068,13 @@ If not set, Gerrit generates this as "gerrit@`hostname`", where
|
|||||||
+
|
+
|
||||||
By default, not set, generating the value at startup.
|
By default, not set, generating the value at startup.
|
||||||
|
|
||||||
|
[[user.anonymousCoward]]user.anonymousCoward::
|
||||||
|
+
|
||||||
|
Username that this displayed in the Gerrit WebUI and in e-mail
|
||||||
|
notifications if the full name of the user is not set.
|
||||||
|
+
|
||||||
|
By default "Anonymous Coward" is used.
|
||||||
|
|
||||||
|
|
||||||
File `etc/secure.config`
|
File `etc/secure.config`
|
||||||
-------------------------
|
-------------------------
|
||||||
|
@@ -42,6 +42,7 @@ public class GerritConfig implements Cloneable {
|
|||||||
protected List<RegexFindReplace> commentLinks;
|
protected List<RegexFindReplace> commentLinks;
|
||||||
protected boolean documentationAvailable;
|
protected boolean documentationAvailable;
|
||||||
protected boolean testChangeMerge;
|
protected boolean testChangeMerge;
|
||||||
|
protected String anonymousCowardName;
|
||||||
|
|
||||||
public String getRegisterUrl() {
|
public String getRegisterUrl() {
|
||||||
return registerUrl;
|
return registerUrl;
|
||||||
@@ -169,4 +170,12 @@ public class GerritConfig implements Cloneable {
|
|||||||
public void setTestChangeMerge(final boolean test) {
|
public void setTestChangeMerge(final boolean test) {
|
||||||
testChangeMerge = test;
|
testChangeMerge = test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAnonymousCowardName() {
|
||||||
|
return anonymousCowardName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnonymousCowardName(final String anonymousCowardName) {
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -109,7 +109,7 @@ public class FormatUtil {
|
|||||||
public static String nameEmail(final AccountInfo acct) {
|
public static String nameEmail(final AccountInfo acct) {
|
||||||
String name = acct.getFullName();
|
String name = acct.getFullName();
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = Gerrit.C.anonymousCoward();
|
name = Gerrit.getConfig().getAnonymousCowardName();
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder b = new StringBuilder();
|
final StringBuilder b = new StringBuilder();
|
||||||
|
@@ -82,7 +82,6 @@ public interface GerritConstants extends Constants {
|
|||||||
String searchButton();
|
String searchButton();
|
||||||
|
|
||||||
String rpcStatusLoading();
|
String rpcStatusLoading();
|
||||||
String anonymousCoward();
|
|
||||||
|
|
||||||
String sectionNavigation();
|
String sectionNavigation();
|
||||||
String sectionActions();
|
String sectionActions();
|
||||||
|
@@ -65,7 +65,6 @@ searchHint = Change #, SHA-1, tr:id, owner:email or reviewer:email
|
|||||||
searchButton = Search
|
searchButton = Search
|
||||||
|
|
||||||
rpcStatusLoading = Loading ...
|
rpcStatusLoading = Loading ...
|
||||||
anonymousCoward = Anonymous Coward
|
|
||||||
|
|
||||||
sectionNavigation = Navigation
|
sectionNavigation = Navigation
|
||||||
sectionActions = Actions
|
sectionActions = Actions
|
||||||
|
@@ -20,6 +20,7 @@ import com.google.gerrit.common.data.GitwebLink;
|
|||||||
import com.google.gerrit.reviewdb.Account;
|
import com.google.gerrit.reviewdb.Account;
|
||||||
import com.google.gerrit.server.account.Realm;
|
import com.google.gerrit.server.account.Realm;
|
||||||
import com.google.gerrit.server.config.AllProjectsName;
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.config.AuthConfig;
|
import com.google.gerrit.server.config.AuthConfig;
|
||||||
import com.google.gerrit.server.config.DownloadSchemeConfig;
|
import com.google.gerrit.server.config.DownloadSchemeConfig;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
@@ -56,13 +57,14 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
|||||||
private EmailSender emailSender;
|
private EmailSender emailSender;
|
||||||
private final ContactStore contactStore;
|
private final ContactStore contactStore;
|
||||||
private final ServletContext servletContext;
|
private final ServletContext servletContext;
|
||||||
|
private final String anonymousCowardName;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc,
|
GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc,
|
||||||
final AuthConfig ac, final GitWebConfig gwc,
|
final AuthConfig ac, final GitWebConfig gwc, final AllProjectsName wp,
|
||||||
final AllProjectsName wp, final SshInfo si,
|
final SshInfo si, final ApprovalTypes at, final ContactStore cs,
|
||||||
final ApprovalTypes at, final ContactStore cs, final ServletContext sc,
|
final ServletContext sc, final DownloadSchemeConfig dc,
|
||||||
final DownloadSchemeConfig dc) {
|
final @AnonymousCowardName String acn) {
|
||||||
realm = r;
|
realm = r;
|
||||||
cfg = gsc;
|
cfg = gsc;
|
||||||
authConfig = ac;
|
authConfig = ac;
|
||||||
@@ -73,6 +75,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
|||||||
approvalTypes = at;
|
approvalTypes = at;
|
||||||
contactStore = cs;
|
contactStore = cs;
|
||||||
servletContext = sc;
|
servletContext = sc;
|
||||||
|
anonymousCowardName = acn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(optional = true)
|
@Inject(optional = true)
|
||||||
@@ -104,6 +107,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
|||||||
.getResource("/Documentation/index.html") != null);
|
.getResource("/Documentation/index.html") != null);
|
||||||
config.setTestChangeMerge(cfg.getBoolean("changeMerge",
|
config.setTestChangeMerge(cfg.getBoolean("changeMerge",
|
||||||
"test", false));
|
"test", false));
|
||||||
|
config.setAnonymousCowardName(anonymousCowardName);
|
||||||
|
|
||||||
final Set<Account.FieldName> fields = new HashSet<Account.FieldName>();
|
final Set<Account.FieldName> fields = new HashSet<Account.FieldName>();
|
||||||
for (final Account.FieldName n : Account.FieldName.values()) {
|
for (final Account.FieldName n : Account.FieldName.values()) {
|
||||||
|
@@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.Project;
|
|||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
import com.google.gerrit.server.account.AccountState;
|
import com.google.gerrit.server.account.AccountState;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.gerrit.server.events.ApprovalAttribute;
|
import com.google.gerrit.server.events.ApprovalAttribute;
|
||||||
@@ -107,6 +108,8 @@ public class ChangeHookRunner {
|
|||||||
/** Filename of the cla signed hook. */
|
/** Filename of the cla signed hook. */
|
||||||
private final File claSignedHook;
|
private final File claSignedHook;
|
||||||
|
|
||||||
|
private final String anonymousCowardName;
|
||||||
|
|
||||||
/** Repository Manager. */
|
/** Repository Manager. */
|
||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
|
|
||||||
@@ -133,11 +136,12 @@ public class ChangeHookRunner {
|
|||||||
@Inject
|
@Inject
|
||||||
public ChangeHookRunner(final WorkQueue queue,
|
public ChangeHookRunner(final WorkQueue queue,
|
||||||
final GitRepositoryManager repoManager,
|
final GitRepositoryManager repoManager,
|
||||||
@GerritServerConfig final Config config, final SitePaths sitePath,
|
final @GerritServerConfig Config config,
|
||||||
final ProjectCache projectCache,
|
final @AnonymousCowardName String anonymousCowardName,
|
||||||
final AccountCache accountCache,
|
final SitePaths sitePath, final ProjectCache projectCache,
|
||||||
final ApprovalTypes approvalTypes,
|
final AccountCache accountCache, final ApprovalTypes approvalTypes,
|
||||||
final EventFactory eventFactory) {
|
final EventFactory eventFactory) {
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.hookQueue = queue.createQueue(1, "hook");
|
this.hookQueue = queue.createQueue(1, "hook");
|
||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
@@ -465,14 +469,14 @@ public class ChangeHookRunner {
|
|||||||
*/
|
*/
|
||||||
private String getDisplayName(final Account account) {
|
private String getDisplayName(final Account account) {
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
String result = (account.getFullName() == null) ? "Anonymous Coward" : account.getFullName();
|
String result = (account.getFullName() == null) ? anonymousCowardName : account.getFullName();
|
||||||
if (account.getPreferredEmail() != null) {
|
if (account.getPreferredEmail() != null) {
|
||||||
result += " (" + account.getPreferredEmail() + ")";
|
result += " (" + account.getPreferredEmail() + ")";
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Anonymous Coward";
|
return anonymousCowardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -26,6 +26,7 @@ import com.google.gerrit.server.account.AccountState;
|
|||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
import com.google.gerrit.server.account.GroupIncludeCache;
|
import com.google.gerrit.server.account.GroupIncludeCache;
|
||||||
import com.google.gerrit.server.account.Realm;
|
import com.google.gerrit.server.account.Realm;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.config.AuthConfig;
|
import com.google.gerrit.server.config.AuthConfig;
|
||||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
@@ -66,6 +67,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
public static class GenericFactory {
|
public static class GenericFactory {
|
||||||
private final CapabilityControl.Factory capabilityControlFactory;
|
private final CapabilityControl.Factory capabilityControlFactory;
|
||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
|
private final String anonymousCowardName;
|
||||||
private final Provider<String> canonicalUrl;
|
private final Provider<String> canonicalUrl;
|
||||||
private final Realm realm;
|
private final Realm realm;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
@@ -75,11 +77,13 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
GenericFactory(
|
GenericFactory(
|
||||||
CapabilityControl.Factory capabilityControlFactory,
|
CapabilityControl.Factory capabilityControlFactory,
|
||||||
final AuthConfig authConfig,
|
final AuthConfig authConfig,
|
||||||
|
final @AnonymousCowardName String anonymousCowardName,
|
||||||
final @CanonicalWebUrl Provider<String> canonicalUrl,
|
final @CanonicalWebUrl Provider<String> canonicalUrl,
|
||||||
final Realm realm, final AccountCache accountCache,
|
final Realm realm, final AccountCache accountCache,
|
||||||
final GroupIncludeCache groupIncludeCache) {
|
final GroupIncludeCache groupIncludeCache) {
|
||||||
this.capabilityControlFactory = capabilityControlFactory;
|
this.capabilityControlFactory = capabilityControlFactory;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
this.canonicalUrl = canonicalUrl;
|
this.canonicalUrl = canonicalUrl;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
@@ -92,15 +96,15 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
|
|
||||||
public IdentifiedUser create(Provider<ReviewDb> db, Account.Id id) {
|
public IdentifiedUser create(Provider<ReviewDb> db, Account.Id id) {
|
||||||
return new IdentifiedUser(capabilityControlFactory, AccessPath.UNKNOWN,
|
return new IdentifiedUser(capabilityControlFactory, AccessPath.UNKNOWN,
|
||||||
authConfig, canonicalUrl, realm, accountCache, groupIncludeCache,
|
authConfig, anonymousCowardName, canonicalUrl, realm, accountCache,
|
||||||
null, db, id);
|
groupIncludeCache, null, db, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdentifiedUser create(AccessPath accessPath,
|
public IdentifiedUser create(AccessPath accessPath,
|
||||||
Provider<SocketAddress> remotePeerProvider, Account.Id id) {
|
Provider<SocketAddress> remotePeerProvider, Account.Id id) {
|
||||||
return new IdentifiedUser(capabilityControlFactory, accessPath,
|
return new IdentifiedUser(capabilityControlFactory, accessPath,
|
||||||
authConfig, canonicalUrl, realm, accountCache, groupIncludeCache,
|
authConfig, anonymousCowardName, canonicalUrl, realm, accountCache,
|
||||||
remotePeerProvider, null, id);
|
groupIncludeCache, remotePeerProvider, null, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +118,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
public static class RequestFactory {
|
public static class RequestFactory {
|
||||||
private final CapabilityControl.Factory capabilityControlFactory;
|
private final CapabilityControl.Factory capabilityControlFactory;
|
||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
|
private final String anonymousCowardName;
|
||||||
private final Provider<String> canonicalUrl;
|
private final Provider<String> canonicalUrl;
|
||||||
private final Realm realm;
|
private final Realm realm;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
@@ -126,6 +131,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
RequestFactory(
|
RequestFactory(
|
||||||
CapabilityControl.Factory capabilityControlFactory,
|
CapabilityControl.Factory capabilityControlFactory,
|
||||||
final AuthConfig authConfig,
|
final AuthConfig authConfig,
|
||||||
|
final @AnonymousCowardName String anonymousCowardName,
|
||||||
final @CanonicalWebUrl Provider<String> canonicalUrl,
|
final @CanonicalWebUrl Provider<String> canonicalUrl,
|
||||||
final Realm realm, final AccountCache accountCache,
|
final Realm realm, final AccountCache accountCache,
|
||||||
final GroupIncludeCache groupIncludeCache,
|
final GroupIncludeCache groupIncludeCache,
|
||||||
@@ -134,6 +140,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
final Provider<ReviewDb> dbProvider) {
|
final Provider<ReviewDb> dbProvider) {
|
||||||
this.capabilityControlFactory = capabilityControlFactory;
|
this.capabilityControlFactory = capabilityControlFactory;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
this.canonicalUrl = canonicalUrl;
|
this.canonicalUrl = canonicalUrl;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
@@ -146,8 +153,8 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
public IdentifiedUser create(final AccessPath accessPath,
|
public IdentifiedUser create(final AccessPath accessPath,
|
||||||
final Account.Id id) {
|
final Account.Id id) {
|
||||||
return new IdentifiedUser(capabilityControlFactory, accessPath,
|
return new IdentifiedUser(capabilityControlFactory, accessPath,
|
||||||
authConfig, canonicalUrl, realm, accountCache, groupIncludeCache,
|
authConfig, anonymousCowardName, canonicalUrl, realm, accountCache,
|
||||||
remotePeerProvider, dbProvider, id);
|
groupIncludeCache, remotePeerProvider, dbProvider, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +188,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
private final GroupIncludeCache groupIncludeCache;
|
private final GroupIncludeCache groupIncludeCache;
|
||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
|
private final String anonymousCowardName;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Provider<SocketAddress> remotePeerProvider;
|
private final Provider<SocketAddress> remotePeerProvider;
|
||||||
@@ -199,7 +207,9 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
private IdentifiedUser(
|
private IdentifiedUser(
|
||||||
CapabilityControl.Factory capabilityControlFactory,
|
CapabilityControl.Factory capabilityControlFactory,
|
||||||
final AccessPath accessPath,
|
final AccessPath accessPath,
|
||||||
final AuthConfig authConfig, final Provider<String> canonicalUrl,
|
final AuthConfig authConfig,
|
||||||
|
final String anonymousCowardName,
|
||||||
|
final Provider<String> canonicalUrl,
|
||||||
final Realm realm, final AccountCache accountCache,
|
final Realm realm, final AccountCache accountCache,
|
||||||
final GroupIncludeCache groupIncludeCache,
|
final GroupIncludeCache groupIncludeCache,
|
||||||
@Nullable final Provider<SocketAddress> remotePeerProvider,
|
@Nullable final Provider<SocketAddress> remotePeerProvider,
|
||||||
@@ -210,6 +220,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
this.groupIncludeCache = groupIncludeCache;
|
this.groupIncludeCache = groupIncludeCache;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
this.remotePeerProvider = remotePeerProvider;
|
this.remotePeerProvider = remotePeerProvider;
|
||||||
this.dbProvider = dbProvider;
|
this.dbProvider = dbProvider;
|
||||||
this.accountId = id;
|
this.accountId = id;
|
||||||
@@ -343,7 +354,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
name = ua.getPreferredEmail();
|
name = ua.getPreferredEmail();
|
||||||
}
|
}
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
name = "Anonymous Coward";
|
name = anonymousCowardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
String user = getUserName();
|
String user = getUserName();
|
||||||
@@ -403,7 +414,7 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
if (0 < at) {
|
if (0 < at) {
|
||||||
name = email.substring(0, at);
|
name = email.substring(0, at);
|
||||||
} else {
|
} else {
|
||||||
name = "Anonymous Coward";
|
name = anonymousCowardName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2011 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.server.config;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
import com.google.inject.BindingAnnotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
|
||||||
|
/** Special name for a user that hasn't set a name. */
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@BindingAnnotation
|
||||||
|
public @interface AnonymousCowardName {
|
||||||
|
}
|
@@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (C) 2011 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.server.config;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
|
||||||
|
public class AnonymousCowardNameProvider implements Provider<String> {
|
||||||
|
|
||||||
|
private final String anonymousCoward;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public AnonymousCowardNameProvider(@GerritServerConfig final Config cfg) {
|
||||||
|
String anonymousCoward = cfg.getString("user", null, "anonymousCoward");
|
||||||
|
if (anonymousCoward == null) {
|
||||||
|
anonymousCoward = "Anonymous Coward";
|
||||||
|
}
|
||||||
|
this.anonymousCoward = anonymousCoward;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get() {
|
||||||
|
return anonymousCoward;
|
||||||
|
}
|
||||||
|
}
|
@@ -24,6 +24,7 @@ import com.google.gerrit.reviewdb.PatchSetApproval;
|
|||||||
import com.google.gerrit.reviewdb.ReviewDb;
|
import com.google.gerrit.reviewdb.ReviewDb;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.gwtorm.client.ResultSet;
|
import com.google.gwtorm.client.ResultSet;
|
||||||
@@ -76,6 +77,7 @@ public class CreateCodeReviewNotes {
|
|||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
private final ApprovalTypes approvalTypes;
|
private final ApprovalTypes approvalTypes;
|
||||||
private final String canonicalWebUrl;
|
private final String canonicalWebUrl;
|
||||||
|
private final String anonymousCowardName;
|
||||||
private final Repository db;
|
private final Repository db;
|
||||||
private final RevWalk revWalk;
|
private final RevWalk revWalk;
|
||||||
private final ObjectInserter inserter;
|
private final ObjectInserter inserter;
|
||||||
@@ -95,15 +97,17 @@ public class CreateCodeReviewNotes {
|
|||||||
@GerritPersonIdent final PersonIdent gerritIdent,
|
@GerritPersonIdent final PersonIdent gerritIdent,
|
||||||
final AccountCache accountCache,
|
final AccountCache accountCache,
|
||||||
final ApprovalTypes approvalTypes,
|
final ApprovalTypes approvalTypes,
|
||||||
@Nullable @CanonicalWebUrl final String canonicalWebUrl,
|
final @Nullable @CanonicalWebUrl String canonicalWebUrl,
|
||||||
@Assisted ReviewDb reviewDb,
|
final @AnonymousCowardName String anonymousCowardName,
|
||||||
@Assisted final Repository db) {
|
final @Assisted ReviewDb reviewDb,
|
||||||
|
final @Assisted Repository db) {
|
||||||
schema = reviewDb;
|
schema = reviewDb;
|
||||||
this.author = gerritIdent;
|
this.author = gerritIdent;
|
||||||
this.gerritIdent = gerritIdent;
|
this.gerritIdent = gerritIdent;
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
this.approvalTypes = approvalTypes;
|
this.approvalTypes = approvalTypes;
|
||||||
this.canonicalWebUrl = canonicalWebUrl;
|
this.canonicalWebUrl = canonicalWebUrl;
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
|
|
||||||
revWalk = new RevWalk(db);
|
revWalk = new RevWalk(db);
|
||||||
@@ -185,7 +189,8 @@ public class CreateCodeReviewNotes {
|
|||||||
throws CodeReviewNoteCreationException, IOException {
|
throws CodeReviewNoteCreationException, IOException {
|
||||||
try {
|
try {
|
||||||
ReviewNoteHeaderFormatter formatter =
|
ReviewNoteHeaderFormatter formatter =
|
||||||
new ReviewNoteHeaderFormatter(author.getTimeZone());
|
new ReviewNoteHeaderFormatter(author.getTimeZone(),
|
||||||
|
anonymousCowardName);
|
||||||
final List<String> idList = commit.getFooterLines(CHANGE_ID);
|
final List<String> idList = commit.getFooterLines(CHANGE_ID);
|
||||||
if (idList.isEmpty())
|
if (idList.isEmpty())
|
||||||
formatter.appendChangeId(change.getKey());
|
formatter.appendChangeId(change.getKey());
|
||||||
|
@@ -37,12 +37,14 @@ import java.util.TimeZone;
|
|||||||
class ReviewNoteHeaderFormatter {
|
class ReviewNoteHeaderFormatter {
|
||||||
|
|
||||||
private final DateFormat rfc2822DateFormatter;
|
private final DateFormat rfc2822DateFormatter;
|
||||||
|
private final String anonymousCowardName;
|
||||||
private final StringBuilder sb = new StringBuilder();
|
private final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
ReviewNoteHeaderFormatter(TimeZone tz) {
|
ReviewNoteHeaderFormatter(TimeZone tz, String anonymousCowardName) {
|
||||||
rfc2822DateFormatter =
|
rfc2822DateFormatter =
|
||||||
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
|
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
|
||||||
rfc2822DateFormatter.setCalendar(Calendar.getInstance(tz, Locale.US));
|
rfc2822DateFormatter.setCalendar(Calendar.getInstance(tz, Locale.US));
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendChangeId(Change.Key changeKey) {
|
void appendChangeId(Change.Key changeKey) {
|
||||||
@@ -76,7 +78,7 @@ class ReviewNoteHeaderFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!wroteData) {
|
if (!wroteData) {
|
||||||
sb.append("Anonymous Coward #").append(user.getId());
|
sb.append(anonymousCowardName).append(" #").append(user.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.mail;
|
package com.google.gerrit.server.mail;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
@@ -26,8 +27,9 @@ public class AbandonedSender extends ReplyToChangeSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AbandonedSender(EmailArguments ea, @Assisted Change c) {
|
public AbandonedSender(EmailArguments ea,
|
||||||
super(ea, c, "abandon");
|
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "abandon");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.mail;
|
package com.google.gerrit.server.mail;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.ssh.SshInfo;
|
import com.google.gerrit.server.ssh.SshInfo;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
@@ -26,9 +27,10 @@ public class AddReviewerSender extends NewChangeSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AddReviewerSender(EmailArguments ea, SshInfo sshInfo,
|
public AddReviewerSender(EmailArguments ea,
|
||||||
|
@AnonymousCowardName String anonymousCowardName, SshInfo sshInfo,
|
||||||
@Assisted Change c) {
|
@Assisted Change c) {
|
||||||
super(ea, sshInfo, c);
|
super(ea, anonymousCowardName, sshInfo, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -57,8 +57,9 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||||||
protected Set<Account.Id> authors;
|
protected Set<Account.Id> authors;
|
||||||
protected boolean emailOnlyAuthors;
|
protected boolean emailOnlyAuthors;
|
||||||
|
|
||||||
protected ChangeEmail(EmailArguments ea, final Change c, final String mc) {
|
protected ChangeEmail(EmailArguments ea, final String anonymousCowardName,
|
||||||
super(ea, mc);
|
final Change c, final String mc) {
|
||||||
|
super(ea, anonymousCowardName, mc);
|
||||||
change = c;
|
change = c;
|
||||||
changeData = change != null ? new ChangeData(change) : null;
|
changeData = change != null ? new ChangeData(change) : null;
|
||||||
emailOnlyAuthors = false;
|
emailOnlyAuthors = false;
|
||||||
|
@@ -17,6 +17,7 @@ package com.google.gerrit.server.mail;
|
|||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
import com.google.gerrit.reviewdb.Patch;
|
import com.google.gerrit.reviewdb.Patch;
|
||||||
import com.google.gerrit.reviewdb.PatchLineComment;
|
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.PatchFile;
|
||||||
import com.google.gerrit.server.patch.PatchList;
|
import com.google.gerrit.server.patch.PatchList;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -41,8 +42,9 @@ public class CommentSender extends ReplyToChangeSender {
|
|||||||
private List<PatchLineComment> inlineComments = Collections.emptyList();
|
private List<PatchLineComment> inlineComments = Collections.emptyList();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CommentSender(EmailArguments ea, @Assisted Change c) {
|
public CommentSender(EmailArguments ea,
|
||||||
super(ea, c, "comment");
|
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "comment");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPatchLineComments(final List<PatchLineComment> plc) {
|
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.Change;
|
||||||
import com.google.gerrit.reviewdb.AccountProjectWatch.NotifyType;
|
import com.google.gerrit.reviewdb.AccountProjectWatch.NotifyType;
|
||||||
import com.google.gerrit.server.account.GroupCache;
|
import com.google.gerrit.server.account.GroupCache;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.ssh.SshInfo;
|
import com.google.gerrit.server.ssh.SshInfo;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -38,9 +39,10 @@ public class CreateChangeSender extends NewChangeSender {
|
|||||||
private final GroupCache groupCache;
|
private final GroupCache groupCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CreateChangeSender(EmailArguments ea, SshInfo sshInfo,
|
public CreateChangeSender(EmailArguments ea,
|
||||||
|
@AnonymousCowardName String anonymousCowardName, SshInfo sshInfo,
|
||||||
GroupCache groupCache, @Assisted Change c) {
|
GroupCache groupCache, @Assisted Change c) {
|
||||||
super(ea, sshInfo, c);
|
super(ea, anonymousCowardName, sshInfo, c);
|
||||||
this.groupCache = groupCache;
|
this.groupCache = groupCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ import com.google.gerrit.common.data.ParameterizedString;
|
|||||||
import com.google.gerrit.reviewdb.Account;
|
import com.google.gerrit.reviewdb.Account;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
@@ -34,6 +35,7 @@ public class FromAddressGeneratorProvider implements
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
FromAddressGeneratorProvider(@GerritServerConfig final Config cfg,
|
FromAddressGeneratorProvider(@GerritServerConfig final Config cfg,
|
||||||
|
final @AnonymousCowardName String anonymousCowardName,
|
||||||
@GerritPersonIdent final PersonIdent myIdent,
|
@GerritPersonIdent final PersonIdent myIdent,
|
||||||
final AccountCache accountCache) {
|
final AccountCache accountCache) {
|
||||||
|
|
||||||
@@ -42,7 +44,9 @@ public class FromAddressGeneratorProvider implements
|
|||||||
|
|
||||||
if (from == null || "MIXED".equalsIgnoreCase(from)) {
|
if (from == null || "MIXED".equalsIgnoreCase(from)) {
|
||||||
ParameterizedString name = new ParameterizedString("${user} (Code Review)");
|
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)) {
|
} else if ("USER".equalsIgnoreCase(from)) {
|
||||||
generator = new UserGen(accountCache, srvAddr);
|
generator = new UserGen(accountCache, srvAddr);
|
||||||
@@ -56,7 +60,9 @@ public class FromAddressGeneratorProvider implements
|
|||||||
if (name == null || name.getParameterNames().isEmpty()) {
|
if (name == null || name.getParameterNames().isEmpty()) {
|
||||||
generator = new ServerGen(a);
|
generator = new ServerGen(a);
|
||||||
} else {
|
} 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 String senderEmail;
|
||||||
private final Address serverAddress;
|
private final Address serverAddress;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
|
private final String anonymousCowardName;
|
||||||
private final ParameterizedString namePattern;
|
private final ParameterizedString namePattern;
|
||||||
|
|
||||||
PatternGen(final Address serverAddress, final AccountCache accountCache,
|
PatternGen(final Address serverAddress, final AccountCache accountCache,
|
||||||
|
final String anonymousCowardName,
|
||||||
final ParameterizedString namePattern, final String senderEmail) {
|
final ParameterizedString namePattern, final String senderEmail) {
|
||||||
this.senderEmail = senderEmail;
|
this.senderEmail = senderEmail;
|
||||||
this.serverAddress = serverAddress;
|
this.serverAddress = serverAddress;
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
this.namePattern = namePattern;
|
this.namePattern = namePattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +150,7 @@ public class FromAddressGeneratorProvider implements
|
|||||||
final Account account = accountCache.get(fromId).getAccount();
|
final Account account = accountCache.get(fromId).getAccount();
|
||||||
String fullName = account.getFullName();
|
String fullName = account.getFullName();
|
||||||
if (fullName == null || "".equals(fullName)) {
|
if (fullName == null || "".equals(fullName)) {
|
||||||
fullName = "Anonymous Coward";
|
fullName = anonymousCowardName;
|
||||||
}
|
}
|
||||||
senderName = namePattern.replace("user", fullName).toString();
|
senderName = namePattern.replace("user", fullName).toString();
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.mail;
|
package com.google.gerrit.server.mail;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
@@ -25,8 +26,9 @@ public class MergeFailSender extends ReplyToChangeSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MergeFailSender(EmailArguments ea, @Assisted Change c) {
|
public MergeFailSender(EmailArguments ea,
|
||||||
super(ea, c, "merge-failed");
|
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "merge-failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,6 +23,7 @@ import com.google.gerrit.reviewdb.ApprovalCategory;
|
|||||||
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
|
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
import com.google.gerrit.reviewdb.PatchSetApproval;
|
import com.google.gerrit.reviewdb.PatchSetApproval;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
@@ -39,8 +40,10 @@ public class MergedSender extends ReplyToChangeSender {
|
|||||||
private final ApprovalTypes approvalTypes;
|
private final ApprovalTypes approvalTypes;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MergedSender(EmailArguments ea, ApprovalTypes at, @Assisted Change c) {
|
public MergedSender(EmailArguments ea,
|
||||||
super(ea, c, "merged");
|
@AnonymousCowardName String anonymousCowardName, ApprovalTypes at,
|
||||||
|
@Assisted Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "merged");
|
||||||
approvalTypes = at;
|
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> reviewers = new HashSet<Account.Id>();
|
||||||
private final Set<Account.Id> extraCC = new HashSet<Account.Id>();
|
private final Set<Account.Id> extraCC = new HashSet<Account.Id>();
|
||||||
|
|
||||||
protected NewChangeSender(EmailArguments ea, SshInfo sshInfo, Change c) {
|
protected NewChangeSender(EmailArguments ea, String anonymousCowardName,
|
||||||
super(ea, c, "newchange");
|
SshInfo sshInfo, Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "newchange");
|
||||||
this.sshInfo = sshInfo;
|
this.sshInfo = sshInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,10 +54,14 @@ public abstract class OutgoingEmail {
|
|||||||
protected VelocityContext velocityContext;
|
protected VelocityContext velocityContext;
|
||||||
|
|
||||||
protected final EmailArguments args;
|
protected final EmailArguments args;
|
||||||
|
private final String anonymousCowardName;
|
||||||
protected Account.Id fromId;
|
protected Account.Id fromId;
|
||||||
|
|
||||||
protected OutgoingEmail(EmailArguments ea, final String mc) {
|
|
||||||
|
protected OutgoingEmail(EmailArguments ea, final String anonymousCowardName,
|
||||||
|
final String mc) {
|
||||||
args = ea;
|
args = ea;
|
||||||
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
messageClass = mc;
|
messageClass = mc;
|
||||||
headers = new LinkedHashMap<String, EmailHeader>();
|
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". */
|
/** 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 "Anonymous Coward";
|
return anonymousCowardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Account userAccount = args.accountCache.get(accountId).getAccount();
|
final Account userAccount = args.accountCache.get(accountId).getAccount();
|
||||||
@@ -235,7 +239,7 @@ public abstract class OutgoingEmail {
|
|||||||
name = userAccount.getPreferredEmail();
|
name = userAccount.getPreferredEmail();
|
||||||
}
|
}
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = "Anonymous Coward #" + accountId;
|
name = anonymousCowardName + " #" + accountId;
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -254,7 +258,7 @@ public abstract class OutgoingEmail {
|
|||||||
return email;
|
return email;
|
||||||
|
|
||||||
} else /* (name == null && email == null) */{
|
} else /* (name == null && email == null) */{
|
||||||
return "Anonymous Coward #" + accountId;
|
return anonymousCowardName + " #" + accountId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.mail;
|
package com.google.gerrit.server.mail;
|
||||||
|
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.config.AuthConfig;
|
import com.google.gerrit.server.config.AuthConfig;
|
||||||
import com.google.gwtjsonrpc.server.XsrfException;
|
import com.google.gwtjsonrpc.server.XsrfException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -33,8 +34,9 @@ public class RegisterNewEmailSender extends OutgoingEmail {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RegisterNewEmailSender(EmailArguments ea, AuthConfig ac,
|
public RegisterNewEmailSender(EmailArguments ea, AuthConfig ac,
|
||||||
|
@AnonymousCowardName String anonymousCowardName,
|
||||||
@Assisted final String address) {
|
@Assisted final String address) {
|
||||||
super(ea, "registernewemail");
|
super(ea, anonymousCowardName, "registernewemail");
|
||||||
authConfig = ac;
|
authConfig = ac;
|
||||||
addr = address;
|
addr = address;
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.mail;
|
|||||||
|
|
||||||
import com.google.gerrit.reviewdb.Account;
|
import com.google.gerrit.reviewdb.Account;
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.ssh.SshInfo;
|
import com.google.gerrit.server.ssh.SshInfo;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
@@ -39,8 +40,10 @@ public class ReplacePatchSetSender extends ReplyToChangeSender {
|
|||||||
private final SshInfo sshInfo;
|
private final SshInfo sshInfo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ReplacePatchSetSender(EmailArguments ea, SshInfo si, @Assisted Change c) {
|
public ReplacePatchSetSender(EmailArguments ea,
|
||||||
super(ea, c, "newpatchset");
|
@AnonymousCowardName String anonymousCowardName, SshInfo si,
|
||||||
|
@Assisted Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "newpatchset");
|
||||||
sshInfo = si;
|
sshInfo = si;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,8 +22,9 @@ public abstract class ReplyToChangeSender extends ChangeEmail {
|
|||||||
public T create(Change change);
|
public T create(Change change);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReplyToChangeSender(EmailArguments ea, Change c, String mc) {
|
protected ReplyToChangeSender(EmailArguments ea, String anonymousCowardName,
|
||||||
super(ea, c, mc);
|
Change c, String mc) {
|
||||||
|
super(ea, anonymousCowardName, c, mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.mail;
|
package com.google.gerrit.server.mail;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
@@ -26,8 +27,9 @@ public class RestoredSender extends ReplyToChangeSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RestoredSender(EmailArguments ea, @Assisted Change c) {
|
public RestoredSender(EmailArguments ea,
|
||||||
super(ea, c, "restore");
|
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "restore");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.mail;
|
package com.google.gerrit.server.mail;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
@@ -25,8 +26,9 @@ public class RevertedSender extends ReplyToChangeSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RevertedSender(EmailArguments ea, @Assisted Change c) {
|
public RevertedSender(EmailArguments ea,
|
||||||
super(ea, c, "revert");
|
@AnonymousCowardName String anonymousCowardName, @Assisted Change c) {
|
||||||
|
super(ea, anonymousCowardName, c, "revert");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,6 +21,8 @@ import com.google.gerrit.server.GerritPersonIdent;
|
|||||||
import com.google.gerrit.server.GerritPersonIdentProvider;
|
import com.google.gerrit.server.GerritPersonIdentProvider;
|
||||||
import com.google.gerrit.server.config.AllProjectsName;
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
|
import com.google.gerrit.server.config.AnonymousCowardNameProvider;
|
||||||
import com.google.gerrit.server.config.FactoryModule;
|
import com.google.gerrit.server.config.FactoryModule;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
|
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
|
||||||
@@ -40,6 +42,9 @@ public class SchemaModule extends FactoryModule {
|
|||||||
.toProvider(AllProjectsNameProvider.class)
|
.toProvider(AllProjectsNameProvider.class)
|
||||||
.in(SINGLETON);
|
.in(SINGLETON);
|
||||||
|
|
||||||
|
bind(String.class).annotatedWith(AnonymousCowardName.class).toProvider(
|
||||||
|
AnonymousCowardNameProvider.class);
|
||||||
|
|
||||||
bind(GitRepositoryManager.class).to(LocalDiskRepositoryManager.class);
|
bind(GitRepositoryManager.class).to(LocalDiskRepositoryManager.class);
|
||||||
install(new LifecycleModule() {
|
install(new LifecycleModule() {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -47,7 +47,8 @@ public class FromAddressGeneratorProviderTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private FromAddressGenerator create() {
|
private FromAddressGenerator create() {
|
||||||
return new FromAddressGeneratorProvider(config, ident, accountCache).get();
|
return new FromAddressGeneratorProvider(config, "Anonymous Coward", ident,
|
||||||
|
accountCache).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFrom(final String newFrom) {
|
private void setFrom(final String newFrom) {
|
||||||
|
Reference in New Issue
Block a user