Cleanup and refactor the e-mail module
Review Request #7560 — Created July 30, 2015 and submitted — Latest diff uploaded
The recipient building portion of
send_review_mailhas been
refactored out into two methods:build_recipients, which returns sets
ofUsers andGroups that should receive the e-mail, as well as
recipients_to_addresses, which builds sets of addresses with fewer
queries than before.The logic of determing the recipients of an e-mail has been moved out
ofsend_review_mailand the signature of the function has changed to
accept theTOandCCfields as sets or lists ofUsers and
Groups. The logic has also been corrected to no longer send e-mails
to the following:
- users who have starred a review request but are no longer in the
review request's local site; - users in the
limit_recipients_tolist who are inactive; and - users in the
limit_recipients_tolist who are no longer part of
the review request's local site.
All methods that call into send_review_mail to send e-mail now must
calculate the addresses they will be sending to. This is to allow for
a future change to allow extensions to filter the TO and CC
fields of e-mails.
A large portion of this change is a style and docstring cleanup to
bring it in line with our style guidelines as well as adding numerous
new unit tests to cover all the behaviour of the two new functions
and ensure it does not regress.
Ran unit tests.