ChangeControl visibility takes draft into account
isVisible() in ChangeControl now considers whether or not the change is a draft. As ReviewDb is needed to see whether or not a user has visibility for a certain change, this change also refactors most uses of isVisible() to also pass in ReviewDb. As a bonus, much of the notification routines seem to work as wanted, due to the new visibility checks. Change-Id: I4c3b068413e4db30edb23f498f61048142cb6713
This commit is contained in:
@@ -401,11 +401,11 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isVisibleTo(final Account.Id to) {
|
||||
protected boolean isVisibleTo(final Account.Id to) throws OrmException {
|
||||
return projectState == null
|
||||
|| change == null
|
||||
|| projectState.controlFor(args.identifiedUserFactory.create(to))
|
||||
.controlFor(change).isVisible();
|
||||
.controlFor(change).isVisible(args.db.get());
|
||||
}
|
||||
|
||||
/** Find all users who are authors of any part of this change. */
|
||||
|
@@ -18,6 +18,7 @@ import com.google.gerrit.reviewdb.Account;
|
||||
import com.google.gerrit.reviewdb.UserIdentity;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.mail.EmailHeader.AddressList;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.velocity.Template;
|
||||
@@ -305,13 +306,17 @@ public abstract class OutgoingEmail {
|
||||
|
||||
/** Schedule delivery of this message to the given account. */
|
||||
protected void add(final RecipientType rt, final Account.Id to) {
|
||||
if (!rcptTo.contains(to) && isVisibleTo(to)) {
|
||||
rcptTo.add(to);
|
||||
add(rt, toAddress(to));
|
||||
try {
|
||||
if (!rcptTo.contains(to) && isVisibleTo(to)) {
|
||||
rcptTo.add(to);
|
||||
add(rt, toAddress(to));
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
log.error("Error reading database for account: " + to, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isVisibleTo(final Account.Id to) {
|
||||
protected boolean isVisibleTo(final Account.Id to) throws OrmException {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user