1414from ietf .person .models import Person
1515from ietf .group .models import Role
1616from ietf .doc .models import Document
17- from ietf .mailtoken .utils import gather_addresses , gather_address_list
17+ from ietf .mailtoken .utils import gather_address_lists
1818
1919def email_state_changed (request , doc , text , mailtoken_id = None ):
20- to = gather_address_list (mailtoken_id or 'doc_state_edited' ,doc = doc )
20+ ( to , cc ) = gather_address_lists (mailtoken_id or 'doc_state_edited' ,doc = doc )
2121 if not to :
2222 return
2323
@@ -26,7 +26,8 @@ def email_state_changed(request, doc, text, mailtoken_id=None):
2626 "ID Tracker State Update Notice: %s" % doc .file_tag (),
2727 "doc/mail/state_changed_email.txt" ,
2828 dict (text = text ,
29- url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()))
29+ url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()),
30+ cc = cc )
3031
3132def email_stream_changed (request , doc , old_stream , new_stream , text = "" ):
3233 """Email the change text to the notify group and to the stream chairs"""
@@ -35,7 +36,7 @@ def email_stream_changed(request, doc, old_stream, new_stream, text=""):
3536 streams .append (old_stream .slug )
3637 if new_stream :
3738 streams .append (new_stream .slug )
38- to = gather_address_list ('doc_stream_changed' ,doc = doc ,streams = streams )
39+ ( to , cc ) = gather_address_lists ('doc_stream_changed' ,doc = doc ,streams = streams )
3940
4041 if not to :
4142 return
@@ -48,12 +49,14 @@ def email_stream_changed(request, doc, old_stream, new_stream, text=""):
4849 "ID Tracker Stream Change Notice: %s" % doc .file_tag (),
4950 "doc/mail/stream_changed_email.txt" ,
5051 dict (text = text ,
51- url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()))
52+ url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()),
53+ cc = cc )
5254
5355def email_pulled_from_rfc_queue (request , doc , comment , prev_state , next_state ):
5456 extra = extra_automation_headers (doc )
55- extra ['Cc' ] = gather_addresses ('doc_pulled_from_rfc_queue_cc' ,doc = doc )
56- send_mail (request , gather_address_list ('doc_pulled_from_rfc_queue' ,doc = doc ), None ,
57+ addrs = gather_address_lists ('doc_pulled_from_rfc_queue' ,doc = doc )
58+ extra ['Cc' ] = addrs .as_strings ().cc
59+ send_mail (request , addrs .to , None ,
5760 "%s changed state from %s to %s" % (doc .name , prev_state .name , next_state .name ),
5861 "doc/mail/pulled_from_rfc_queue_email.txt" ,
5962 dict (doc = doc ,
@@ -112,12 +115,14 @@ def generate_last_call_announcement(request, doc):
112115 else :
113116 ipr_links = None
114117
118+
119+ addrs = gather_address_lists ('last_call_issued' ,doc = doc ).as_strings ()
115120 mail = render_to_string ("doc/mail/last_call_announcement.txt" ,
116121 dict (doc = doc ,
117122 doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url () + "ballot/" ,
118123 expiration_date = expiration_date .strftime ("%Y-%m-%d" ), #.strftime("%B %-d, %Y"),
119- to = gather_addresses ( 'last_call_issued' , doc = doc ) ,
120- cc = gather_addresses ( 'last_call_issued_cc' , doc = doc ) ,
124+ to = addrs . to ,
125+ cc = addrs . cc ,
121126 group = group ,
122127 docs = [ doc ],
123128 urls = [ settings .IDTRACKER_BASE_URL + doc .get_absolute_url () ],
@@ -187,12 +192,13 @@ def generate_approval_mail_approved(request, doc):
187192
188193 doc_type = "RFC" if doc .get_state_slug () == "rfc" else "Internet Draft"
189194
195+ addrs = gather_address_lists ('ballot_approved_ietf_stream' ,doc = doc ).as_strings ()
190196 return render_to_string ("doc/mail/approval_mail.txt" ,
191197 dict (doc = doc ,
192198 docs = [doc ],
193199 doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
194- to = gather_addresses ( 'ballot_approved_ietf_stream' , doc = doc ),
195- cc = gather_addresses ( 'ballot_approved_ietf_stream_cc' , doc = doc ) ,
200+ to = addrs . to ,
201+ cc = addrs . cc ,
196202 doc_type = doc_type ,
197203 made_by = made_by ,
198204 contacts = contacts ,
@@ -205,14 +211,15 @@ def generate_approval_mail_rfc_editor(request, doc):
205211 # which does not happen now that we have conflict reviews.
206212 disapproved = doc .get_state_slug ("draft-iesg" ) in DO_NOT_PUBLISH_IESG_STATES
207213 doc_type = "RFC" if doc .get_state_slug () == "rfc" else "Internet Draft"
214+ addrs = gather_address_lists ('ballot_approved_conflrev' , doc = doc ).as_strings ()
208215
209216 return render_to_string ("doc/mail/approval_mail_rfc_editor.txt" ,
210217 dict (doc = doc ,
211218 doc_url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
212219 doc_type = doc_type ,
213220 disapproved = disapproved ,
214- to = gather_addresses ( 'ballot_approved_conflrev' , doc = doc ) ,
215- cc = gather_addresses ( 'ballot_approved_conflrev_cc' , doc = doc ) ,
221+ to = addrs . to ,
222+ cc = addrs . cc ,
216223 )
217224 )
218225
@@ -242,8 +249,7 @@ def generate_publication_request(request, doc):
242249 )
243250
244251def send_last_call_request (request , doc ):
245- to = gather_addresses ('last_call_requested' ,doc = doc )
246- cc = gather_addresses ('last_call_requested_cc' ,doc = doc )
252+ (to , cc ) = gather_address_lists ('last_call_requested' ,doc = doc )
247253 frm = '"DraftTracker Mail System" <iesg-secretary@ietf.org>'
248254
249255 send_mail (request , to , frm ,
@@ -255,7 +261,7 @@ def send_last_call_request(request, doc):
255261 cc = cc )
256262
257263def email_resurrect_requested (request , doc , by ):
258- to = gather_address_list ('resurrection_requested' ,doc = doc )
264+ ( to , cc ) = gather_address_lists ('resurrection_requested' ,doc = doc )
259265
260266 if by .role_set .filter (name = "secr" , group__acronym = "secretariat" ):
261267 e = by .role_email ("secr" , group = "secretariat" )
@@ -268,39 +274,43 @@ def email_resurrect_requested(request, doc, by):
268274 "doc/mail/resurrect_request_email.txt" ,
269275 dict (doc = doc ,
270276 by = frm ,
271- url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()))
277+ url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()),
278+ cc = cc )
272279
273280def email_resurrection_completed (request , doc , requester ):
274- to = gather_address_list ('resurrection_completed' ,doc = doc )
281+ ( to , cc ) = gather_address_lists ('resurrection_completed' ,doc = doc )
275282 frm = "I-D Administrator <internet-drafts-reply@ietf.org>"
276283 send_mail (request , to , frm ,
277284 "I-D Resurrection Completed - %s" % doc .file_tag (),
278285 "doc/mail/resurrect_completed_email.txt" ,
279286 dict (doc = doc ,
280287 by = frm ,
281- url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()))
288+ url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()),
289+ cc = cc )
282290
283291def email_ballot_deferred (request , doc , by , telechat_date ):
284- to = gather_addresses ('ballot_deferred' ,doc = doc )
292+ ( to , cc ) = gather_address_lists ('ballot_deferred' ,doc = doc )
285293 frm = "DraftTracker Mail System <iesg-secretary@ietf.org>"
286294 send_mail (request , to , frm ,
287295 "IESG Deferred Ballot notification: %s" % doc .file_tag (),
288296 "doc/mail/ballot_deferred_email.txt" ,
289297 dict (doc = doc ,
290298 by = by ,
291299 action = 'deferred' ,
292- telechat_date = telechat_date ))
300+ telechat_date = telechat_date ),
301+ cc = cc )
293302
294303def email_ballot_undeferred (request , doc , by , telechat_date ):
295- to = gather_addresses ('ballot_deferred' ,doc = doc )
304+ ( to , cc ) = gather_address_lists ('ballot_deferred' ,doc = doc )
296305 frm = "DraftTracker Mail System <iesg-secretary@ietf.org>"
297306 send_mail (request , to , frm ,
298307 "IESG Undeferred Ballot notification: %s" % doc .file_tag (),
299308 "doc/mail/ballot_deferred_email.txt" ,
300309 dict (doc = doc ,
301310 by = by ,
302311 action = 'undeferred' ,
303- telechat_date = telechat_date ))
312+ telechat_date = telechat_date ),
313+ cc = cc )
304314
305315def generate_issue_ballot_mail (request , doc , ballot ):
306316 active_ads = Person .objects .filter (role__name = "ad" , role__group__state = "active" , role__group__type = "area" ).distinct ()
@@ -370,7 +380,7 @@ def formatted(val):
370380 )
371381 )
372382
373- def email_iana (request , doc , to , msg ):
383+ def email_iana (request , doc , to , msg , cc = None ):
374384 # fix up message and send it with extra info on doc in headers
375385 import email
376386 parsed_msg = email .message_from_string (msg .encode ("utf-8" ))
@@ -383,7 +393,8 @@ def email_iana(request, doc, to, msg):
383393 send_mail_text (request , "IANA <%s>" % to ,
384394 parsed_msg ["From" ], parsed_msg ["Subject" ],
385395 parsed_msg .get_payload (),
386- extra = extra )
396+ extra = extra ,
397+ cc = cc )
387398
388399def extra_automation_headers (doc ):
389400 extra = {}
@@ -394,24 +405,24 @@ def extra_automation_headers(doc):
394405
395406def email_last_call_expired (doc ):
396407 text = "IETF Last Call has ended, and the state has been changed to\n %s." % doc .get_state ("draft-iesg" ).name
408+ addrs = gather_address_lists ('last_call_expired' ,doc = doc )
397409
398410 send_mail (None ,
399- gather_addresses ( 'last_call_expired' , doc = doc ) ,
411+ addrs . to ,
400412 "DraftTracker Mail System <iesg-secretary@ietf.org>" ,
401413 "Last Call Expired: %s" % doc .file_tag (),
402414 "doc/mail/change_notice.txt" ,
403415 dict (text = text ,
404416 doc = doc ,
405417 url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url ()),
406- cc = gather_addresses ('last_call_expired_cc' ,doc = doc )
407- )
418+ cc = addrs .cc )
408419
409420def email_stream_state_changed (request , doc , prev_state , new_state , by , comment = "" ):
410- recipients = gather_address_list ('doc_stream_state_edited' ,doc = doc )
421+ ( to , cc ) = gather_address_lists ('doc_stream_state_edited' ,doc = doc )
411422
412423 state_type = (prev_state or new_state ).type
413424
414- send_mail (request , recipients , settings .DEFAULT_FROM_EMAIL ,
425+ send_mail (request , to , settings .DEFAULT_FROM_EMAIL ,
415426 u"%s changed for %s" % (state_type .label , doc .name ),
416427 'doc/mail/stream_state_changed_email.txt' ,
417428 dict (doc = doc ,
@@ -420,46 +431,39 @@ def email_stream_state_changed(request, doc, prev_state, new_state, by, comment=
420431 prev_state = prev_state ,
421432 new_state = new_state ,
422433 by = by ,
423- comment = comment ))
434+ comment = comment ),
435+ cc = cc )
424436
425437def email_stream_tags_changed (request , doc , added_tags , removed_tags , by , comment = "" ):
426438
427- recipients = gather_address_list ('doc_stream_state_edited' ,doc = doc )
439+ ( to , cc ) = gather_address_lists ('doc_stream_state_edited' ,doc = doc )
428440
429- send_mail (request , recipients , settings .DEFAULT_FROM_EMAIL ,
441+ send_mail (request , to , settings .DEFAULT_FROM_EMAIL ,
430442 u"Tags changed for %s" % doc .name ,
431443 'doc/mail/stream_tags_changed_email.txt' ,
432444 dict (doc = doc ,
433445 url = settings .IDTRACKER_BASE_URL + doc .get_absolute_url (),
434446 added = added_tags ,
435447 removed = removed_tags ,
436448 by = by ,
437- comment = comment ))
449+ comment = comment ),
450+ cc = cc )
438451
439452def send_review_possibly_replaces_request (request , doc ):
440- to_email = []
441-
442- if doc .stream_id == "ietf" :
443- to_email .extend (r .formatted_email () for r in Role .objects .filter (group = doc .group , name = "chair" ).select_related ("email" , "person" ))
444- elif doc .stream_id == "iab" :
445- to_email .append ("IAB Stream <iab-stream@iab.org>" )
446- elif doc .stream_id == "ise" :
447- to_email .append ("Independent Submission Editor <rfc-ise@rfc-editor.org>" )
448- elif doc .stream_id == "irtf" :
449- to_email .append ("IRSG <irsg@irtf.org>" )
453+ addrs = gather_address_lists ('doc_replacement_suggested' ,doc = doc )
454+ to = set (addrs .to )
455+ cc = set (addrs .cc )
450456
451457 possibly_replaces = Document .objects .filter (name__in = [alias .name for alias in doc .related_that_doc ("possibly-replaces" )])
452- other_chairs = Role .objects .filter (group__in = [other .group for other in possibly_replaces ], name = "chair" ).select_related ("email" , "person" )
453- to_email .extend (r .formatted_email () for r in other_chairs )
454-
455- if not to_email :
456- to_email .append ("internet-drafts@ietf.org" )
457-
458- if to_email :
459- send_mail (request , list (set (to_email )), settings .DEFAULT_FROM_EMAIL ,
460- 'Review of suggested possible replacements for %s-%s needed' % (doc .name , doc .rev ),
461- 'doc/mail/review_possibly_replaces_request.txt' , {
462- 'doc' : doc ,
463- 'possibly_replaces' : doc .related_that_doc ("possibly-replaces" ),
464- 'review_url' : settings .IDTRACKER_BASE_URL + urlreverse ("doc_review_possibly_replaces" , kwargs = { "name" : doc .name }),
465- })
458+ for other_doc in possibly_replaces :
459+ (other_to , other_cc ) = gather_address_lists ('doc_replacement_suggested' ,doc = other_doc )
460+ to .update (other_to )
461+ cc .update (other_cc )
462+
463+ send_mail (request , list (to ), settings .DEFAULT_FROM_EMAIL ,
464+ 'Review of suggested possible replacements for %s-%s needed' % (doc .name , doc .rev ),
465+ 'doc/mail/review_possibly_replaces_request.txt' ,
466+ dict (doc = doc ,
467+ possibly_replaces = doc .related_that_doc ("possibly-replaces" ),
468+ review_url = settings .IDTRACKER_BASE_URL + urlreverse ("doc_review_possibly_replaces" , kwargs = { "name" : doc .name })),
469+ cc = list (cc ),)
0 commit comments