def getNotificationRecipients(self, min_level): """See IBranchMergeProposal.getNotificationRecipients""" recipients = {} branch_identity_cache = { self.source_branch: self.source_branch.bzr_identity, self.target_branch: self.target_branch.bzr_identity, } branches = [self.source_branch, self.target_branch] if self.prerequisite_branch is not None: branches.append(self.prerequisite_branch) for branch in branches: branch_recipients = branch.getNotificationRecipients() for recipient in branch_recipients: # If the recipient cannot see either of the branches, skip # them. if (not self.source_branch.visibleByUser(recipient) or not self.target_branch.visibleByUser(recipient)): continue subscription, rationale = branch_recipients.getReason( recipient) if (subscription.review_level < min_level): continue recipients[recipient] = RecipientReason.forBranchSubscriber( subscription, recipient, rationale, self, branch_identity_cache=branch_identity_cache) # Add in all the individuals that have been asked for a review, # or who have reviewed. These people get added to the recipients # with the rationale of "Reviewer". # Don't add a team reviewer to the recipients as they are only going # to get emails normally if they are subscribed to one of the # branches, and if they are subscribed, they'll be getting this email # aleady. for review in self.votes: reviewer = review.reviewer pending = review.comment is None recipients[reviewer] = RecipientReason.forReviewer( self, pending, reviewer, branch_identity_cache=branch_identity_cache) # If the registrant of the proposal is getting emails, update the # rationale to say that they registered it. Don't however send them # emails if they aren't asking for any. if self.registrant in recipients: recipients[self.registrant] = RecipientReason.forRegistrant( self, branch_identity_cache=branch_identity_cache) # If the owner of the source branch is getting emails, override the # rationale to say they are the owner of the souce branch. source_owner = self.source_branch.owner if source_owner in recipients: reason = RecipientReason.forSourceOwner( self, branch_identity_cache=branch_identity_cache) if reason is not None: recipients[source_owner] = reason return recipients