Jump to >

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:
unregister_email_hook(signal, handler)[source]

Unregister an e-mail hook.

Parameters:
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 the mail_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 the mail_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 the mail_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 (through mail_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:
webapi_token_deleted_cb(instance, **kwargs)[source]

Send e-mail when an API token is deleted.

Parameters:
connect_signals()[source]

Connect e-mail callbacks to signals.

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.

__init__(*args, **kwargs)[source]
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 given user 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 in limit_recipients_to will be used.

Parameters:
Returns:

A 2-tuple of the To field and the CC field, as sets of Users and Groups.

Return type:

tuple

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 and Groups.
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 and Groups.
  • cc_field (list) – The addresses to be CC’ed on the e-mail. This should be a list of Users and Groups.
  • 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:

unicode

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 not None it must be one of SUBMITTED or DISCARDED.
mail_review(review, user, request)[source]

Send an e-mail representing the supplied review.

Parameters:
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:
Raises:

ValueError – The provided op 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 and Groups.
  • cc_field (set) – The original CC field of the e-mail, as a set of Users and Groups.
  • 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 and Groups.

Return type:

tuple