Skip to content

Commit 14b6437

Browse files
didomdfcoding
authored andcommitted
Add transition from 'Bounced' to 'Delivered' (pypi#10378)
1 parent c9c0a5b commit 14b6437

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/unit/email/ses/test_models.py

+11
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,17 @@ def test_complain_without_email_obj_and_with(self, db_session):
214214

215215
assert em.missing
216216

217+
def test_delivery_after_hard_bounce(self, db_session):
218+
email = EmailFactory.create(transient_bounces=3)
219+
em = EmailMessageFactory.create(to=email.email)
220+
221+
status = EmailStatus.load(em)
222+
status.bounce()
223+
status.deliver()
224+
225+
assert email.transient_bounces == 0
226+
assert not email.verified
227+
217228
@pytest.mark.parametrize(
218229
"start_status",
219230
["Accepted", "Delivered", "Bounced", "Soft Bounced", "Complained"],

warehouse/email/ses/models.py

+9
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ def _reset_transient_bounce(self):
177177
collector=lambda iterable: list(iterable)[-1],
178178
)
179179

180+
# This happens sometimes. The email will stay unverfied, but this allows us
181+
# to record the event
182+
bounced.upon(
183+
deliver,
184+
enter=delivered,
185+
outputs=[_reset_transient_bounce],
186+
collector=lambda iterable: list(iterable)[-1],
187+
)
188+
180189
# Serialization / Deserialization
181190

182191
@_machine.serializer()

0 commit comments

Comments
 (0)