reviewboard.notifications.email¶
-
HEADER_ADDITIONAL_CHARACTERS_LENGTH
= 26[source]¶ The number of additional characters each
X-ReviewBoard-Diff-For
has.We calculate the length the value of each header at runtime. However,
X-ReviewBoard-Diff-For: `` is present before the value, and the line terminates with a ``\r\n
.
-
register_email_hook
(signal, handler)[source]¶ Register an e-mail hook.
Parameters: - signal (django.dispatch.Signal) – The signal that will trigger the e-mail to be sent. This is one of
review_request_published
,review_request_closed
,review_published
, orreply_published
. - handler (reviewboard.extensions.hooks.EmailHook) – The
EmailHook
that will be triggered when an e-mail of the chosen type is about to be sent.
- signal (django.dispatch.Signal) – The signal that will trigger the e-mail to be sent. This is one of
-
unregister_email_hook
(signal, handler)[source]¶ Unregister an e-mail hook.
Parameters: - signal (django.dispatch.Signal) – The signal that will trigger the e-mail to be sent. This is one of
review_request_published
,review_request_closed
,review_published
, orreply_published
. - handler (reviewboard.extensions.hooks.EmailHook) – The
EmailHook
that will be triggered when an e-mail of the chosen type is about to be sent.
- signal (django.dispatch.Signal) – The signal that will trigger the e-mail to be sent. This is one of
-
review_request_closed_cb
(sender, user, review_request, type, **kwargs)[source]¶ Send e-mail when a review request is closed.
Listens to the
review_request_closed
signal and sends an e-mail if this type of notification is enabled (through themail_send_review_close_mail
site configuration setting).
-
review_request_published_cb
(sender, user, review_request, trivial, changedesc, **kwargs)[source]¶ Send e-mail when a review request is published.
Listens to the
review_request_published
signal and sends an e-mail if this type of notification is enabled through themail_send_review_mail
site configuration setting).
-
review_published_cb
(sender, user, review, request, **kwargs)[source]¶ Send e-mail when a review is published.
Listens to the
review_published
signal and sends e-mail if this type of notification is enabled through themail_send_review_mail
site configuration setting).
-
reply_published_cb
(sender, user, reply, trivial, **kwargs)[source]¶ Send e-mail when a review reply is published.
Listens to the
reply_published
signal and sends an e-mail if this type of notification is enabled (throughmail_send_review_mail
site configuration).
-
user_registered_cb
(user, **kwargs)[source]¶ Send e-mail when a user is registered.
Listens for new user registrations and sends a new user registration e-mail to administrators, if this type of notification is enabled (through
mail_send_new_user_mail
site configuration).
-
webapi_token_saved_cb
(instance, created, **kwargs)[source]¶ Send e-mail when an API token is created or updated.
Parameters: - instance (reviewboard.webapi.models.WebAPIToken) – The token that has been created or updated.
- created (bool) – Whether or not the token is created.
- **kwargs (dict) – Unused keyword arguments provided by the signal.
-
webapi_token_deleted_cb
(instance, **kwargs)[source]¶ Send e-mail when an API token is deleted.
Parameters: - instance (reviewboard.webapi.models.WebAPIToken) – The token that has been deleted.
- **kwargs (dict) – Unused keyword arguments provided by the signal.
-
get_email_addresses_for_group
(group, review_request_id=None)[source]¶ Build a list of e-mail addresses for the group.
Parameters: group (reviewboard.reviews.models.Group) – The review group to build the e-mail addresses for. Returns: A list of properly formatted e-mail addresses for all users in the review group. Return type: list
-
class
EmailMessage
(*args, **kwargs)[source]¶ Bases:
djblets.mail.message.EmailMessage
The Review Board EmailMessage subclass.
This class only differs from Djblets’
EmailMessage
by using the site configuration to generate some e-mail settings.
-
build_recipients
(user, review_request, extra_recipients=None, limit_recipients_to=None)[source]¶ Build the recipient sets for an e-mail.
By default, the user sending the e-mail, the review request submitter (if they are active), all active reviewers, and all active members of review groups will be recipients of the e-mail.
If the
limit_recipients_to
parameter is provided, the givenuser
and the review request submitter (if active) will still be recipients of the e-mail, but all reviewers and members of review groups will not. Instead, the recipients given inlimit_recipients_to
will be used.Parameters: - user (django.contrib.auth.models.User) – The user sending the e-mail.
- review_request (reviewboard.reviews.models.ReviewRequest) – The review request the e-mail corresponds to.
- extra_recipients (list) – An optional list of extra recipients as
Users
andGroups
that will receive the e-mail. - limit_recipients_to (list) – An optional list of recipients as
Users
andGroups
who will receive the e-mail in place of the normal recipients.
Returns: A 2-tuple of the To field and the CC field, as sets of
Users
andGroups
.Return type:
-
recipients_to_addresses
(recipients, review_request_id=None)[source]¶ Return the set of e-mail addresses for the recipients.
Parameters: recipients (list) – A list of Users
andGroups
.Returns: The e-mail addresses for all recipients. Return type: set
-
send_review_mail
(user, review_request, subject, in_reply_to, to_field, cc_field, text_template_name, html_template_name, context=None, extra_headers=None)[source]¶ Format and send an e-mail out.
Parameters: - user (django.contrib.auth.models.User) – The user who is sending the e-mail.
- review_request (reviewboard.reviews.models.ReviewRequest) – The review request that the e-mail is about.
- subject (unicode) – The subject of the e-mail address.
- in_reply_to (unicode) – The e-mail message ID for threading.
- to_field (list) – The recipients to send the e-mail to. This should be a list of
Users
andGroups
. - cc_field (list) – The addresses to be CC’ed on the e-mail. This should be a list of
Users
andGroups
. - text_template_name (unicode) – The name for the text e-mail template.
- html_template_name (unicode) – The name for the HTML e-mail template.
- context (dict) – Optional extra context to provide to the template.
- extra_headers (dict) – Either a dict or
MultiValueDict
providing additional headers to send with the e-mail.
Returns: The resulting e-mail message ID.
Return type:
-
mail_review_request
(review_request, user, changedesc=None, close_type=None)[source]¶ Send an e-mail representing the supplied review request.
Parameters: - review_request (reviewboard.reviews.models.ReviewRequest) – The review request to send an e-mail about.
- user (django.contrib.auth.models.User) – The user who triggered the e-mail (i.e., they published or closed the review request).
- changedesc (reviewboard.changedescs.models.ChangeDescription) – An optional change description showing what has changed in the
review request, possibly with explanatory text from the submitter.
This is created when saving a draft on a public review request and
will be
None
when publishing initially. This is used by the template to add contextual (updated) flags to inform people what has changed. - close_type (unicode) – How the review request was closed or
None
if it was published. If this is notNone
it must be one ofSUBMITTED
orDISCARDED
.
-
mail_review
(review, user, request)[source]¶ Send an e-mail representing the supplied review.
Parameters: - review (reviewboard.reviews.models.Review) – The review to send an e-mail about.
- user (django.contrib.auth.models.User) – The user who published the review.
- request (django.http.HttpRequest) – The request object if the review was published from an HTTP request.
-
mail_reply
(reply, user)[source]¶ Send an e-mail representing the supplied reply to a review.
Parameters: reply (reviewboard.reviews.models.Review) – The review reply to send an e-mail about.
-
mail_new_user
(user)[source]¶ Send an e-mail to administrators for newly registered users.
Parameters: user (django.contrib.auth.models.User) – The user to send an e-mail about.
-
mail_webapi_token
(webapi_token, op)[source]¶ Send an e-mail about an API token update.
This will inform the user about a newly-created, updated, or deleted token.
Parameters: - webapi_token (reviewboard.webapi.models.WebAPIToken) – The API token the e-mail is about.
- op (unicode) – The operation the email is about. This is one of
created
,updated
, ordeleted
.
Raises: ValueError
– The providedop
argument was invalid.
-
filter_email_recipients_from_hooks
(to_field, cc_field, signal, **kwargs)[source]¶ Filter the e-mail recipients through configured e-mail hooks.
Parameters: - to_field (set) – The original To field of the e-mail, as a set of
Users
andGroups
. - cc_field (set) – The original CC field of the e-mail, as a set of
Users
andGroups
. - signal (django.dispatch.Signal) – The signal that triggered the e-mail.
- **kwargs (dict) – Extra keyword arguments to pass to the e-mail hook.
Returns: A 2-tuple of the To field and the CC field, as sets of
Users
andGroups
.Return type: - to_field (set) – The original To field of the e-mail, as a set of