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_mail
has been
refactored out into two methods:build_recipients
, which returns sets
ofUser
s andGroup
s 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_mail
and the signature of the function has changed to
accept theTO
andCC
fields as sets or lists ofUser
s and
Group
s. 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_to
list who are inactive; and - users in the
limit_recipients_to
list 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.