Search in sources :

Example 1 with NotifyHandling

use of com.google.gerrit.extensions.api.changes.NotifyHandling in project gerrit by GerritCodeReview.

the class PostReviewers method prepareApplication.

public Addition prepareApplication(ChangeResource rsrc, AddReviewerInput input, boolean allowGroup) throws OrmException, IOException, PermissionBackendException {
    String reviewer = input.reviewer;
    ReviewerState state = input.state();
    NotifyHandling notify = input.notify;
    ListMultimap<RecipientType, Account.Id> accountsToNotify = null;
    try {
        accountsToNotify = notifyUtil.resolveAccounts(input.notifyDetails);
    } catch (BadRequestException e) {
        return fail(reviewer, e.getMessage());
    }
    boolean confirmed = input.confirmed();
    boolean allowByEmail = projectCache.checkedGet(rsrc.getProject()).isEnableReviewerByEmail();
    Addition byAccountId = addByAccountId(reviewer, rsrc, state, notify, accountsToNotify, allowGroup, allowByEmail);
    if (byAccountId != null) {
        return byAccountId;
    }
    Addition wholeGroup = addWholeGroup(reviewer, rsrc, state, notify, accountsToNotify, confirmed, allowGroup, allowByEmail);
    if (wholeGroup != null) {
        return wholeGroup;
    }
    return addByEmail(reviewer, rsrc, state, notify, accountsToNotify);
}
Also used : ReviewerState(com.google.gerrit.extensions.client.ReviewerState) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) NotifyHandling(com.google.gerrit.extensions.api.changes.NotifyHandling) RecipientType(com.google.gerrit.extensions.api.changes.RecipientType)

Example 2 with NotifyHandling

use of com.google.gerrit.extensions.api.changes.NotifyHandling in project gerrit by GerritCodeReview.

the class ReplaceOp method postUpdate.

@Override
public void postUpdate(Context ctx) throws Exception {
    if (changeKind != ChangeKind.TRIVIAL_REBASE) {
        // TODO(dborowitz): Merge email templates so we only have to send one.
        Runnable e = new ReplaceEmailTask(ctx);
        if (requestScopePropagator != null) {
            @SuppressWarnings("unused") Future<?> possiblyIgnoredError = sendEmailExecutor.submit(requestScopePropagator.wrap(e));
        } else {
            e.run();
        }
    }
    NotifyHandling notify = magicBranch != null && magicBranch.notify != null ? magicBranch.notify : NotifyHandling.ALL;
    if (shouldPublishComments()) {
        emailCommentsFactory.create(notify, magicBranch != null ? magicBranch.getAccountsToNotify() : ImmutableListMultimap.of(), notes, newPatchSet, ctx.getUser().asIdentifiedUser(), msg, comments, msg.getMessage(), // TODO(dborowitz): Include labels.
        ImmutableList.of()).sendAsync();
    }
    revisionCreated.fire(notes.getChange(), newPatchSet, ctx.getAccount(), ctx.getWhen(), notify);
    try {
        fireCommentAddedEvent(ctx);
    } catch (Exception e) {
        log.warn("comment-added event invocation failed", e);
    }
    if (mergedByPushOp != null) {
        mergedByPushOp.postUpdate(ctx);
    }
}
Also used : NotifyHandling(com.google.gerrit.extensions.api.changes.NotifyHandling) OrmException(com.google.gwtorm.server.OrmException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) IOException(java.io.IOException)

Aggregations

NotifyHandling (com.google.gerrit.extensions.api.changes.NotifyHandling)2 RecipientType (com.google.gerrit.extensions.api.changes.RecipientType)1 ReviewerState (com.google.gerrit.extensions.client.ReviewerState)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 OrmException (com.google.gwtorm.server.OrmException)1 IOException (java.io.IOException)1