diff --git a/hc/api/tests/test_bounce.py b/hc/api/tests/test_bounce.py index 46562345..7835abc7 100644 --- a/hc/api/tests/test_bounce.py +++ b/hc/api/tests/test_bounce.py @@ -54,3 +54,13 @@ class BounceTestCase(BaseTestCase): url = "/api/v1/notifications/%s/bounce" % self.n.code r = self.client.get(url) self.assertEqual(r.status_code, 405) + + def test_does_not_unsubscribe_transient_bounces(self): + url = "/api/v1/notifications/%s/bounce?type=Transient" % self.n.code + self.client.post(url, "foo", content_type="text/plain") + + self.n.refresh_from_db() + self.assertEqual(self.n.error, "foo") + + self.channel.refresh_from_db() + self.assertTrue(self.channel.email_verified) diff --git a/hc/api/views.py b/hc/api/views.py index 2e7a9830..4604aa79 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -272,8 +272,9 @@ def bounce(request, code): notification.error = request.body.decode()[:200] notification.save() - notification.channel.email_verified = False - notification.channel.save() + if request.GET.get("type") in (None, "Permanent"): + notification.channel.email_verified = False + notification.channel.save() return HttpResponse()