When draft email aliases are generated, the content of the doc.notify field is used to generate the .notify alias, and is also included in the .all alias. If the notify field contains either the .notify alias or the .all alias, this can create a mail loop. Changed the alias generation code to expand (or ignore, for .notify) aliases found in the notify field, and changed the code which fills in the notify field with a default value to insert the author, ad, and shepherd aliases instead of the .all alias.
- Legacy-Id: 8994
This commit is contained in:
parent
85945683dc
commit
58cc1e431f
|
@ -25,10 +25,8 @@ TODO:
|
|||
|
||||
"""
|
||||
|
||||
DRAFT_EMAIL_SUFFIX='@tools.ietf.org'
|
||||
|
||||
# boilerplate (from various other ietf/bin scripts)
|
||||
import os, sys
|
||||
import os, sys, re
|
||||
filename = os.path.abspath(__file__)
|
||||
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
||||
sys.path = [ basedir ] + sys.path
|
||||
|
@ -72,13 +70,27 @@ def get_draft_notify_emails(draft):
|
|||
if not n:
|
||||
return []
|
||||
l = []
|
||||
draft_email = draft.name + DRAFT_EMAIL_SUFFIX
|
||||
ad_email_alias_regex = "^%s\.ad@(%s|%s)$" % (draft.name, settings.DRAFT_ALIAS_DOMAIN, settings.TOOLS_SERVER)
|
||||
all_email_alias_regex = "^%s\.all@(%s|%s)$" % (draft.name, settings.DRAFT_ALIAS_DOMAIN, settings.TOOLS_SERVER)
|
||||
author_email_alias_regex = "^%s@(%s|%s)$" % (draft.name, settings.DRAFT_ALIAS_DOMAIN, settings.TOOLS_SERVER)
|
||||
notify_email_alias_regex = "^%s\.notify@(%s|%s)$" % (draft.name, settings.DRAFT_ALIAS_DOMAIN, settings.TOOLS_SERVER)
|
||||
shepherd_email_alias_regex = "^%s\.shepherd@(%s|%s)$" % (draft.name, settings.DRAFT_ALIAS_DOMAIN, settings.TOOLS_SERVER)
|
||||
for e in n.split(','):
|
||||
# If the draft name itself is listed as notify list element, we
|
||||
# expand it (to make results better verifiable with the old ones)
|
||||
# If one of the directly expandable aliases are listed in the notify
|
||||
# list, we expand it
|
||||
e = e.strip()
|
||||
if e == draft_email:
|
||||
if re.search(ad_email_alias_regex, e):
|
||||
l.extend(get_draft_ad_emails(draft))
|
||||
elif re.search(author_email_alias_regex, e):
|
||||
l.extend(get_draft_authors_emails(draft))
|
||||
elif re.search(shepherd_email_alias_regex, e):
|
||||
l.extend(get_draft_shepherd_email(draft))
|
||||
elif re.search(all_email_alias_regex, e):
|
||||
l.extend(get_draft_ad_emails(draft))
|
||||
l.extend(get_draft_authors_emails(draft))
|
||||
l.extend(get_draft_shepherd_email(draft))
|
||||
elif re.search(notify_email_alias_regex, e):
|
||||
pass
|
||||
else:
|
||||
l.append(e)
|
||||
# Alternative: if we don't want to do expansion, just this would be
|
||||
|
@ -148,4 +160,4 @@ if __name__ == '__main__':
|
|||
|
||||
afile.close()
|
||||
vfile.close()
|
||||
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ class ConflictReviewTests(TestCase):
|
|||
# Regenerate does not save!
|
||||
self.assertEqual(doc.notify,newlist)
|
||||
q = PyQuery(r.content)
|
||||
self.assertTrue('draft-imaginary-irtf-submission@tools.ietf.org' in q('form input[name=notify]')[0].value)
|
||||
self.assertTrue('draft-imaginary-irtf-submission@ietf.org' in q('form input[name=notify]')[0].value)
|
||||
self.assertTrue('irtf-chair@ietf.org' in q('form input[name=notify]')[0].value)
|
||||
self.assertTrue('foo@bar.baz.com' not in q('form input[name=notify]')[0].value)
|
||||
|
||||
|
|
|
@ -1090,7 +1090,9 @@ class AdoptDraftTests(TestCase):
|
|||
self.assertEqual(draft.stream_id, "ietf")
|
||||
self.assertEqual(draft.docevent_set.count() - events_before, 5)
|
||||
self.assertTrue(mars.list_email in draft.notify)
|
||||
self.assertTrue('draft-ietf-mars-test.all@tools.ietf.org' in draft.notify)
|
||||
self.assertTrue('draft-ietf-mars-test@ietf.org' in draft.notify)
|
||||
self.assertTrue('draft-ietf-mars-test.ad@ietf.org' in draft.notify)
|
||||
self.assertTrue('draft-ietf-mars-test.shepherd@ietf.org' in draft.notify)
|
||||
self.assertEqual(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("state changed" in outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("marschairman@ietf.org" in unicode(outbox[-1]))
|
||||
|
|
|
@ -483,14 +483,16 @@ def get_initial_notify(doc,extra=None):
|
|||
for a in doc.authors.all():
|
||||
receivers.append(a.address)
|
||||
else:
|
||||
receivers.append("%s-chairs@%s" % (doc.group.acronym, settings.TOOLS_SERVER))
|
||||
receivers.append("%s-chairs@%s" % (doc.group.acronym, settings.DRAFT_ALIAS_DOMAIN))
|
||||
for editor in Email.objects.filter(role__name="editor", role__group=doc.group):
|
||||
receivers.append(editor.address)
|
||||
|
||||
if doc.group.list_email:
|
||||
receivers.append(doc.group.list_email)
|
||||
|
||||
receivers.append("%s.all@%s" % (doc.name, settings.TOOLS_SERVER))
|
||||
receivers.append("%s@%s" % (doc.name, settings.DRAFT_ALIAS_DOMAIN))
|
||||
receivers.append("%s.ad@%s" % (doc.name, settings.DRAFT_ALIAS_DOMAIN))
|
||||
receivers.append("%s.shepherd@%s" % (doc.name, settings.DRAFT_ALIAS_DOMAIN))
|
||||
|
||||
elif doc.type.slug=='charter':
|
||||
receivers.extend([role.person.formatted_email() for role in doc.group.role_set.filter(name__slug__in=['ad','chair','secr','techadv'])])
|
||||
|
@ -502,7 +504,7 @@ def get_initial_notify(doc,extra=None):
|
|||
if relation.relationship.slug=='conflrev':
|
||||
doc_to_review = relation.target.document
|
||||
receivers.extend([x.person.formatted_email() for x in Role.objects.filter(group__acronym=doc_to_review.stream.slug,name='chair')])
|
||||
receivers.append("%s@%s" % (doc_to_review.name, settings.TOOLS_SERVER))
|
||||
receivers.append("%s@%s" % (doc_to_review.name, settings.DRAFT_ALIAS_DOMAIN))
|
||||
elif relation.relationship.slug in STATUSCHANGE_RELATIONS:
|
||||
affected_doc = relation.target.document
|
||||
if affected_doc.notify:
|
||||
|
|
|
@ -367,7 +367,7 @@ def build_notify_addresses(doc_to_review):
|
|||
# Take care to do the right thing during ietf chair and stream owner transitions
|
||||
notify_addresses = []
|
||||
notify_addresses.extend([r.formatted_email() for r in Role.objects.filter(group__acronym=doc_to_review.stream.slug, name='chair')])
|
||||
notify_addresses.append("%s@%s" % (doc_to_review.name, settings.TOOLS_SERVER))
|
||||
notify_addresses.append("%s@%s" % (doc_to_review.name, settings.DRAFT_ALIAS_DOMAIN))
|
||||
return notify_addresses
|
||||
|
||||
def build_conflict_review_document(login, doc_to_review, ad, notify, create_in_state):
|
||||
|
|
|
@ -447,6 +447,10 @@ BADNESS_MUCHTOOBIG = 500
|
|||
SELENIUM_TESTS = False
|
||||
SELENIUM_TESTS_ONLY = False
|
||||
|
||||
# Domain which hosts draft and wg alias lists
|
||||
DRAFT_ALIAS_DOMAIN = IETF_DOMAIN
|
||||
GROUP_ALIAS_DOMAIN = IETF_DOMAIN
|
||||
|
||||
# Path to the email alias lists. Used by ietf.utils.aliases
|
||||
DRAFT_ALIASES_PATH = "/a/postfix/draft-aliases"
|
||||
DRAFT_VIRTUAL_PATH = "/a/postfix/draft-virtual"
|
||||
|
|
Loading…
Reference in a new issue