Search in sources :

Example 1 with DeleteReviewerSender

use of com.google.gerrit.server.mail.send.DeleteReviewerSender in project gerrit by GerritCodeReview.

the class DeleteReviewerByEmailOp method postUpdate.

@Override
public void postUpdate(Context ctx) {
    if (!NotifyUtil.shouldNotify(input.notify, input.notifyDetails)) {
        return;
    }
    try {
        DeleteReviewerSender cm = deleteReviewerSenderFactory.create(ctx.getProject(), changeId);
        cm.setFrom(ctx.getAccountId());
        cm.addReviewersByEmail(Collections.singleton(reviewer));
        cm.setChangeMessage(changeMessage.getMessage(), changeMessage.getWrittenOn());
        cm.setNotify(input.notify);
        cm.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
        cm.send();
    } catch (Exception err) {
        log.error("Cannot email update for change " + changeId, err);
    }
}
Also used : DeleteReviewerSender(com.google.gerrit.server.mail.send.DeleteReviewerSender) OrmException(com.google.gwtorm.server.OrmException)

Example 2 with DeleteReviewerSender

use of com.google.gerrit.server.mail.send.DeleteReviewerSender in project gerrit by GerritCodeReview.

the class DeleteReviewerOp method emailReviewers.

private void emailReviewers(Project.NameKey projectName, Change change, ChangeMessage changeMessage) {
    Account.Id userId = user.get().getAccountId();
    if (userId.equals(reviewer.getId())) {
        // The user knows they removed themselves, don't bother emailing them.
        return;
    }
    try {
        DeleteReviewerSender cm = deleteReviewerSenderFactory.create(projectName, change.getId());
        cm.setFrom(userId);
        cm.addReviewers(Collections.singleton(reviewer.getId()));
        cm.setChangeMessage(changeMessage.getMessage(), changeMessage.getWrittenOn());
        cm.setNotify(input.notify);
        cm.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
        cm.send();
    } catch (Exception err) {
        log.error("Cannot email update for change " + change.getId(), err);
    }
}
Also used : DeleteReviewerSender(com.google.gerrit.server.mail.send.DeleteReviewerSender) Account(com.google.gerrit.reviewdb.client.Account) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) OrmException(com.google.gwtorm.server.OrmException) AuthException(com.google.gerrit.extensions.restapi.AuthException)

Aggregations

DeleteReviewerSender (com.google.gerrit.server.mail.send.DeleteReviewerSender)2 OrmException (com.google.gwtorm.server.OrmException)2 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 Account (com.google.gerrit.reviewdb.client.Account)1