def forReviewRequest(cls, reason, merge_proposal, from_user):
     """Return a mailer for a request to review a BranchMergeProposal."""
     from_address = cls._format_user_address(from_user)
     recipients = {reason.subscriber: reason}
     return cls(
         '%(proposal_title)s',
         'review-requested.txt', recipients,
         merge_proposal, from_address, message_id=get_msgid(),
         preview_diff=merge_proposal.preview_diff, direct_email=True)
Exemplo n.º 2
0
 def forReviewRequest(cls, reason, merge_proposal, from_user):
     """Return a mailer for a request to review a BranchMergeProposal."""
     from_address = format_address_for_person(from_user)
     recipients = {reason.subscriber: reason}
     return cls('%(proposal_title)s',
                'review-requested.txt',
                recipients,
                merge_proposal,
                from_address,
                message_id=get_msgid(),
                preview_diff=merge_proposal.preview_diff,
                direct_email=True)
Exemplo n.º 3
0
def create_mail_for_directoryMailBox(from_addr, to_addrs, subject, body,
                                     headers=None):
    """Create a email in the DirectoryMailBox."""
    mc = MailController(from_addr, to_addrs, subject, body, headers)
    message = mc.makeMessage()
    if 'message-id' not in message:
        message['Message-Id'] = get_msgid()
    if 'date' not in message:
        message['Date'] = formatdate()
    # Since this is faking incoming email, set the X-Original-To.
    message['X-Original-To'] = to_addrs
    mailbox = getUtility(IMailBox)
    msg_file = open(
        os.path.join(mailbox.mail_dir, message['Message-Id']), 'w')
    msg_file.write(message.as_string())
    msg_file.close()
Exemplo n.º 4
0
def create_mail_for_directoryMailBox(from_addr,
                                     to_addrs,
                                     subject,
                                     body,
                                     headers=None):
    """Create a email in the DirectoryMailBox."""
    mc = MailController(from_addr, to_addrs, subject, body, headers)
    message = mc.makeMessage()
    if 'message-id' not in message:
        message['Message-Id'] = get_msgid()
    if 'date' not in message:
        message['Date'] = formatdate()
    # Since this is faking incoming email, set the X-Original-To.
    message['X-Original-To'] = to_addrs
    mailbox = getUtility(IMailBox)
    msg_file = open(os.path.join(mailbox.mail_dir, message['Message-Id']), 'w')
    msg_file.write(message.as_string())
    msg_file.close()
    def forModification(cls, merge_proposal, delta_text, from_user):
        """Return a mailer for BranchMergeProposal creation.

        :param merge_proposal: The BranchMergeProposal that was created.
        :param from_user: The user that the creation notification should
            come from.  Optional.
        """
        recipients = merge_proposal.getNotificationRecipients(
            CodeReviewNotificationLevel.STATUS)
        if from_user is not None:
            assert from_user.preferredemail is not None, (
                'The sender must have an email address.')
            from_address = cls._format_user_address(from_user)
        else:
            from_address = config.canonical.noreply_from_address
        return cls(
            '%(proposal_title)s',
            'branch-merge-proposal-updated.txt', recipients,
            merge_proposal, from_address, delta=delta_text,
            message_id=get_msgid())
    def forCreation(cls, merge_proposal, from_user):
        """Return a mailer for BranchMergeProposal creation.

        :param merge_proposal: The BranchMergeProposal that was created.
        :param from_user: The user that the creation notification should
            come from.
        """
        recipients = merge_proposal.getNotificationRecipients(
            CodeReviewNotificationLevel.STATUS)

        assert from_user.preferredemail is not None, (
            'The sender must have an email address.')
        from_address = cls._format_user_address(from_user)

        return cls(
            '%(proposal_title)s',
            'branch-merge-proposal-created.txt', recipients, merge_proposal,
            from_address, message_id=get_msgid(),
            requested_reviews=merge_proposal.votes,
            preview_diff=merge_proposal.preview_diff)
Exemplo n.º 7
0
    def forModification(cls, merge_proposal, delta_text, from_user):
        """Return a mailer for BranchMergeProposal creation.

        :param merge_proposal: The BranchMergeProposal that was created.
        :param from_user: The user that the creation notification should
            come from.  Optional.
        """
        recipients = merge_proposal.getNotificationRecipients(
            CodeReviewNotificationLevel.STATUS)
        if from_user is not None:
            assert from_user.preferredemail is not None, (
                'The sender must have an email address.')
            from_address = format_address_for_person(from_user)
        else:
            from_address = config.canonical.noreply_from_address
        return cls('%(proposal_title)s',
                   'branch-merge-proposal-updated.txt',
                   recipients,
                   merge_proposal,
                   from_address,
                   delta=delta_text,
                   message_id=get_msgid())
Exemplo n.º 8
0
    def forCreation(cls, merge_proposal, from_user):
        """Return a mailer for BranchMergeProposal creation.

        :param merge_proposal: The BranchMergeProposal that was created.
        :param from_user: The user that the creation notification should
            come from.
        """
        recipients = merge_proposal.getNotificationRecipients(
            CodeReviewNotificationLevel.STATUS)

        assert from_user.preferredemail is not None, (
            'The sender must have an email address.')
        from_address = format_address_for_person(from_user)

        return cls('%(proposal_title)s',
                   'branch-merge-proposal-created.txt',
                   recipients,
                   merge_proposal,
                   from_address,
                   message_id=get_msgid(),
                   requested_reviews=merge_proposal.votes,
                   preview_diff=merge_proposal.preview_diff)