Do not include project watchers on new draft changes

If a draft change is created by pushing to refs/drafts/master only
the reviewers explicitly named on the command line (which may be
empty) should be notified of the change. Users watching the project
should not be notified, as the change has not yet been published.

Change-Id: I703ea779106c025c8002e79d39c060208b2e119d
(cherry picked from commit 8690a108f6)
This commit is contained in:
Shawn Pearce
2014-12-10 15:54:52 -08:00
committed by David Pursehouse
parent f208205635
commit 202f02835a

View File

@@ -45,30 +45,32 @@ public class CreateChangeSender extends NewChangeSender {
protected void init() throws EmailException {
super.init();
try {
// Try to mark interested owners with TO and CC or BCC line.
Watchers matching = getWatchers(NotifyType.NEW_CHANGES);
for (Account.Id user : Iterables.concat(
matching.to.accounts,
matching.cc.accounts,
matching.bcc.accounts)) {
if (isOwnerOfProjectOrBranch(user)) {
add(RecipientType.TO, user);
if (change.getStatus() == Change.Status.NEW) {
try {
// Try to mark interested owners with TO and CC or BCC line.
Watchers matching = getWatchers(NotifyType.NEW_CHANGES);
for (Account.Id user : Iterables.concat(
matching.to.accounts,
matching.cc.accounts,
matching.bcc.accounts)) {
if (isOwnerOfProjectOrBranch(user)) {
add(RecipientType.TO, user);
}
}
// Add everyone else. Owners added above will not be duplicated.
add(RecipientType.TO, matching.to);
add(RecipientType.CC, matching.cc);
add(RecipientType.BCC, matching.bcc);
} catch (OrmException err) {
// Just don't CC everyone. Better to send a partial message to those
// we already have queued up then to fail deliver entirely to people
// who have a lower interest in the change.
log.warn("Cannot notify watchers for new change", err);
}
// Add everyone else. Owners added above will not be duplicated.
add(RecipientType.TO, matching.to);
add(RecipientType.CC, matching.cc);
add(RecipientType.BCC, matching.bcc);
} catch (OrmException err) {
// Just don't CC everyone. Better to send a partial message to those
// we already have queued up then to fail deliver entirely to people
// who have a lower interest in the change.
log.warn("Cannot notify watchers for new change", err);
includeWatchers(NotifyType.NEW_PATCHSETS);
}
includeWatchers(NotifyType.NEW_PATCHSETS);
}
private boolean isOwnerOfProjectOrBranch(Account.Id user) {