Skip to main content

Mail recipients

Recipient Triggers Template Code
submission_confirmers sub_announced_to_authors, sub_confirmation_requested, sub_management_url_requested
    def gather_submission_confirmers(self, **kwargs):
        """If a submitted document is revising an existing document, the confirmers 
           are the authors of that existing document, and the chairs if the document is
           a working group document and the author list has changed. Otherwise, the confirmers
           are the authors and submitter of the submitted document."""

        addrs=[]
        if 'submission' in kwargs:
            submission = kwargs['submission']
            doc=submission.existing_document()
            if doc:
                old_authors = [ author for author in doc.documentauthor_set.all() if author.email ]

                addrs.extend([ author.formatted_email() for author in old_authors])

                old_author_email_set = set(author.email.address for author in old_authors)
                new_author_email_set = set(author["email"] for author in submission.authors if author.get("email"))

                if doc.group and old_author_email_set != new_author_email_set:
                    if doc.group.features.acts_like_wg:
                        addrs.extend(Recipient.objects.get(slug='group_chairs').gather(**{'group':doc.group}))
                    elif doc.group.type_id in ['area']:
                        addrs.extend(Recipient.objects.get(slug='group_responsible_directors').gather(**{'group':doc.group}))
                    else:
                        pass
                    if doc.stream_id and doc.stream_id not in ['ietf']:
                        addrs.extend(Recipient.objects.get(slug='stream_managers').gather(**{'streams':[doc.stream_id]}))
            else:
                # This is a bit roundabout, but we do it to get consistent and unicode-compliant
                # email names for known persons, without relying on the name parsed from the
                # draft (which might be ascii, also for persons with non-ascii names)
                emails = [ Email.objects.filter(address=author['email']).first() or author for author in submission.authors if author.get('email') ]
                addrs.extend([ e.formatted_email() if isinstance(e, Email) else formataddr((e["name"], e["email"])) for e in emails ] )
                submitter_email = submission.submitter_parsed()["email"]
                if submitter_email and not submitter_email in [ parseaddr(a)[1] for a in addrs ]:
                    addrs.append(submission.submitter)
        return addrs