Skip to content

Commit 612f33e

Browse files
fix: Don't send I-D expiration warning if it will happen within 12 hours. (ietf-tools#4700)
* fix: 4635 * fix: use timezone.now rather than datetime.datetime.now * chore: fix merge error Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
1 parent d7e3bdd commit 612f33e

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

ietf/doc/expire.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ def send_expire_warning_for_draft(doc):
8787
return # don't warn about dead or inactive documents
8888

8989
expiration = doc.expires.astimezone(DEADLINE_TZINFO).date()
90+
now_plus_12hours = timezone.now() + datetime.timedelta(hours=12)
91+
soon = now_plus_12hours.date()
92+
if expiration <= soon:
93+
# The document will expire very soon, which will send email to the
94+
# same people, so do not send the warning at this point in time
95+
return
96+
9097

9198
(to,cc) = gather_address_lists('doc_expires_soon',doc=doc)
9299

ietf/doc/tests_draft.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def test_warn_expirable_drafts(self):
659659

660660
self.assertEqual(len(list(get_soon_to_expire_drafts(14))), 0)
661661

662-
# hack into expirable state
662+
# hack into expirable state to expire in 10 days
663663
draft.set_state(State.objects.get(type_id='draft-iesg',slug='idexists'))
664664
draft.expires = timezone.now() + datetime.timedelta(days=10)
665665
draft.save_with_history([DocEvent.objects.create(doc=draft, rev=draft.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
@@ -675,8 +675,17 @@ def test_warn_expirable_drafts(self):
675675
self.assertTrue('draft-ietf-mars-test@' in outbox[-1]['To']) # Gets the authors
676676
self.assertTrue('mars-chairs@ietf.org' in outbox[-1]['Cc'])
677677
self.assertTrue('aread@' in outbox[-1]['Cc'])
678+
679+
# hack into expirable state to expire in 10 hours
680+
draft.expires = timezone.now() + datetime.timedelta(hours=10)
681+
draft.save_with_history([DocEvent.objects.create(doc=draft, rev=draft.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
682+
683+
# test send warning is not sent for a document so close to expiration
684+
mailbox_before = len(outbox)
685+
send_expire_warning_for_draft(draft)
686+
self.assertEqual(len(outbox), mailbox_before)
678687

679-
#Check that we don't sent expiration warnings for dead or replaced drafts
688+
# Check that we don't sent expiration warnings for dead or replaced drafts
680689
old_state = draft.get_state_slug("draft-iesg")
681690
mailbox_before = len(outbox)
682691
draft.set_state(State.objects.get(type_id="draft-iesg",slug="dead"))

0 commit comments

Comments
 (0)