Do not email reviewers adding themselves as reviewers

Normally an email is sent to a reviewer when they are added
as a reviewer on a change.  In the special case that they
are the ones adding themselves as a reviwer, do not bother
sending them the notification email.

Change-Id: Id4c98325bd0e0c8cd141de5fd4fc57b13e258553
This commit is contained in:
Martin Fick 2011-05-17 21:46:25 -06:00
parent 0908bff975
commit 2b18baeb0e

View File

@ -132,11 +132,16 @@ class AddReviewer extends Handler<ReviewerResult> {
// Email the reviewers
//
final AddReviewerSender cm;
cm = addReviewerSenderFactory.create(control.getChange());
cm.setFrom(currentUser.getAccountId());
cm.addReviewers(added);
cm.send();
// The user knows they added themselves, don't bother emailing them.
added.remove(currentUser.getAccountId());
if (!added.isEmpty()) {
final AddReviewerSender cm;
cm = addReviewerSenderFactory.create(control.getChange());
cm.setFrom(currentUser.getAccountId());
cm.addReviewers(added);
cm.send();
}
result.setChange(changeDetailFactory.create(changeId).call());
return result;