Merge branch 'stable-2.10'
* stable-2.10: Don't show 'Add Me' button for change owner or existing reviewers Clarify behaviour of the 'Remove Reviewer' permission for change owners Include all command arguments in SSH log entry Honor expireAfterWrite in the H2CacheImpl ACL: Fix transitions check & a '1' in RefName Fix exception when clicking on binary file without being signed in Use current time for cherry picked commits Enable scrollbars for "Edit Commit Message" TextArea Only create All-Projects ACL once Fix inconsistent behaviour when adding reviewers Conflicts: gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheFactory.java gerrit-gwtui/src/main/java/com/google/gerrit/client/change/Reviewers.java gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java Change-Id: I120ce5cc0ac117673c36d96cad301c4ac0982915
This commit is contained in:
@@ -151,11 +151,12 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
|
||||
private PostResult putAccount(ReviewerResource rsrc) throws OrmException,
|
||||
IOException {
|
||||
Account.Id id = rsrc.getUser().getAccountId();
|
||||
ChangeControl control = rsrc.getControl().forUser(
|
||||
identifiedUserFactory.create(id));
|
||||
Account member = rsrc.getUser().getAccount();
|
||||
ChangeControl control = rsrc.getControl();
|
||||
PostResult result = new PostResult();
|
||||
addReviewers(rsrc, result, ImmutableMap.of(id, control));
|
||||
if (isValidReviewer(member, control)) {
|
||||
addReviewers(rsrc, result, ImmutableMap.of(member.getId(), control));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -206,13 +207,8 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
}
|
||||
|
||||
for (Account member : members) {
|
||||
if (member.isActive()) {
|
||||
IdentifiedUser user = identifiedUserFactory.create(member.getId());
|
||||
// Does not account for draft status as a user might want to let a
|
||||
// reviewer see a draft.
|
||||
if (control.forUser(user).isRefVisible()) {
|
||||
reviewers.put(user.getAccountId(), control);
|
||||
}
|
||||
if (isValidReviewer(member, control)) {
|
||||
reviewers.put(member.getId(), control);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,6 +216,16 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isValidReviewer(Account member, ChangeControl control) {
|
||||
if (member.isActive()) {
|
||||
IdentifiedUser user = identifiedUserFactory.create(member.getId());
|
||||
// Does not account for draft status as a user might want to let a
|
||||
// reviewer see a draft.
|
||||
return control.forUser(user).isRefVisible();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addReviewers(ChangeResource rsrc, PostResult result,
|
||||
Map<Account.Id, ChangeControl> reviewers)
|
||||
throws OrmException, IOException {
|
||||
|
Reference in New Issue
Block a user