hc.api.views.bounce handles transient email bounces (logs error, does not disable the integration)

This commit is contained in:
Pēteris Caune 2020-01-08 10:50:29 +02:00
parent 74ad152cc5
commit c521b44d20
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
2 changed files with 13 additions and 2 deletions

View File

@ -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)

View File

@ -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()