From b8108906f48ad85300cf2dfa643cef540139716b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Wed, 8 Jan 2020 11:14:34 +0200 Subject: [PATCH] hc.api.views.bounce updates Channel.last_error --- hc/api/tests/test_bounce.py | 1 + hc/api/views.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hc/api/tests/test_bounce.py b/hc/api/tests/test_bounce.py index 7835abc7..e123f5ec 100644 --- a/hc/api/tests/test_bounce.py +++ b/hc/api/tests/test_bounce.py @@ -29,6 +29,7 @@ class BounceTestCase(BaseTestCase): self.channel.refresh_from_db() self.assertFalse(self.channel.email_verified) + self.assertEqual(self.channel.last_error, "foo") def test_it_checks_ttl(self): self.n.created = self.n.created - timedelta(minutes=60) diff --git a/hc/api/views.py b/hc/api/views.py index 4604aa79..ca5f5333 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -272,9 +272,13 @@ def bounce(request, code): notification.error = request.body.decode()[:200] notification.save() + notification.channel.last_error = notification.error if request.GET.get("type") in (None, "Permanent"): + # For permanent bounces, mark the channel as not verified, so we + # will not try to deliver to it again. notification.channel.email_verified = False - notification.channel.save() + + notification.channel.save() return HttpResponse()