Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transition from 'Bounced' to 'Delivered' #10378

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add transition from 'Bounced' to 'Delivered'
di committed Nov 17, 2021
commit c20f6c2e5b2a784a1cf68dbc3795618b6a3a021a
11 changes: 11 additions & 0 deletions tests/unit/email/ses/test_models.py
Original file line number Diff line number Diff line change
@@ -214,6 +214,17 @@ def test_complain_without_email_obj_and_with(self, db_session):

assert em.missing

def test_delivery_after_hard_bounce(self, db_session):
email = EmailFactory.create(transient_bounces=3)
em = EmailMessageFactory.create(to=email.email)

status = EmailStatus.load(em)
status.bounce()
status.deliver()

assert email.transient_bounces == 0
assert not email.verified

@pytest.mark.parametrize(
"start_status",
["Accepted", "Delivered", "Bounced", "Soft Bounced", "Complained"],
9 changes: 9 additions & 0 deletions warehouse/email/ses/models.py
Original file line number Diff line number Diff line change
@@ -177,6 +177,15 @@ def _reset_transient_bounce(self):
collector=lambda iterable: list(iterable)[-1],
)

# This happens sometimes. The email will stay unverfied, but this allows us
# to record the event
bounced.upon(
deliver,
enter=delivered,
outputs=[_reset_transient_bounce],
collector=lambda iterable: list(iterable)[-1],
)

# Serialization / Deserialization

@_machine.serializer()