Implement reviewers visibility check for suggestions

When suggesting reviews from the accounts index, we need to keep
the visibility check in the same way we were doing for the DB
lookup: filter the suggested reviewer using the visibility check
control.

This was a regression in Gerrit 2.13, noticed by users that started
to adopt the new index mechanism; previously, the DB based suggestion
was already using the visibility check and was correctly hiding
unwanted reviewers.

Bug: Issue 4715
Change-Id: Id569d47d7f728f4556634fed284646fb129c6ef6
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Luca Milanesio
2016-12-18 22:53:17 +00:00
committed by Edwin Kempin
parent d062a34e83
commit 9b51298d05
2 changed files with 19 additions and 3 deletions

View File

@@ -178,13 +178,14 @@ public class ReviewersUtil {
throws OrmException {
AccountIndex searchIndex = indexes.getSearchIndex();
if (searchIndex != null) {
return suggestAccountsFromIndex(suggestReviewers);
return suggestAccountsFromIndex(suggestReviewers, visibilityControl);
}
return suggestAccountsFromDb(suggestReviewers, visibilityControl);
}
private Collection<AccountInfo> suggestAccountsFromIndex(
SuggestReviewers suggestReviewers) throws OrmException {
SuggestReviewers suggestReviewers, VisibilityControl visibilityControl)
throws OrmException {
try {
Map<Account.Id, AccountInfo> matches = new LinkedHashMap<>();
QueryResult<AccountState> result = queryProcessor
@@ -192,7 +193,9 @@ public class ReviewersUtil {
.query(queryBuilder.defaultQuery(suggestReviewers.getQuery()));
for (AccountState accountState : result.entities()) {
Account.Id id = accountState.getAccount().getId();
matches.put(id, accountLoader.get(id));
if (visibilityControl.isVisibleTo(id)) {
matches.put(id, accountLoader.get(id));
}
}
accountLoader.fill();