use of com.google.gerrit.server.change.AttentionSetUnchangedOp in project gerrit by GerritCodeReview.
the class DeleteVote method apply.
@Override
public Response<Object> apply(VoteResource rsrc, DeleteVoteInput input) throws RestApiException, UpdateException, IOException, ConfigInvalidException {
if (input == null) {
input = new DeleteVoteInput();
}
if (input.label != null && !rsrc.getLabel().equals(input.label)) {
throw new BadRequestException("label must match URL");
}
if (input.notify == null) {
input.notify = NotifyHandling.ALL;
}
ReviewerResource r = rsrc.getReviewer();
Change change = r.getChange();
if (r.getRevisionResource() != null && !r.getRevisionResource().isCurrent()) {
throw new MethodNotAllowedException("Cannot delete vote on non-current patch set");
}
try (BatchUpdate bu = updateFactory.create(change.getProject(), r.getChangeResource().getUser(), TimeUtil.now())) {
bu.setNotify(notifyResolver.resolve(firstNonNull(input.notify, NotifyHandling.ALL), input.notifyDetails));
bu.addOp(change.getId(), new Op(projectCache.get(r.getChange().getProject()).orElseThrow(illegalState(r.getChange().getProject())), r.getReviewerUser().state(), rsrc.getLabel(), input));
if (!input.ignoreAutomaticAttentionSetRules && !r.getReviewerUser().getAccountId().equals(currentUserProvider.get().getAccountId())) {
bu.addOp(change.getId(), attentionSetOpFactory.create(r.getReviewerUser().getAccountId(), /* reason= */
"Their vote was deleted", /* notify= */
false));
}
if (input.ignoreAutomaticAttentionSetRules) {
bu.addOp(change.getId(), new AttentionSetUnchangedOp());
}
bu.execute();
}
return Response.none();
}
use of com.google.gerrit.server.change.AttentionSetUnchangedOp in project gerrit by GerritCodeReview.
the class ReplyAttentionSetUpdates method updateAttentionSet.
/**
* Adjusts the attention set by adding and removing users. If the same user should be added and
* removed or added/removed twice, the user will only be added/removed once, based on first
* addition/removal.
*/
public void updateAttentionSet(BatchUpdate bu, ChangeNotes changeNotes, ReviewInput input, CurrentUser currentUser) throws BadRequestException, IOException, PermissionBackendException, UnprocessableEntityException, ConfigInvalidException {
processManualUpdates(bu, changeNotes, input);
if (input.ignoreAutomaticAttentionSetRules) {
// If we ignore automatic attention set rules it means we need to pass this information to
// ChangeUpdate. Also, we should stop all other attention set updates that are part of
// this method and happen in PostReview.
bu.addOp(changeNotes.getChangeId(), new AttentionSetUnchangedOp());
return;
}
boolean isReadyForReview = isReadyForReview(changeNotes, input);
if (isReadyForReview && serviceUserClassifier.isServiceUser(currentUser.getAccountId())) {
botsWithNegativeLabelsAddOwnerAndUploader(bu, changeNotes, input);
return;
}
processRules(bu, changeNotes, isReadyForReview, currentUser, getAllNewComments(changeNotes, input, currentUser));
}
Aggregations