forked from GithubBackups/healthchecks
In api.views.notification_status, always return HTTP 200 so the other party doesn't retry over and over again
This commit is contained in:
parent
697cb19bde
commit
a29b82a0ed
@ -57,7 +57,11 @@ class NotificationStatusTestCase(BaseTestCase):
|
|||||||
self.n.save()
|
self.n.save()
|
||||||
|
|
||||||
r = self.client.post(self.url, {"MessageStatus": "failed"})
|
r = self.client.post(self.url, {"MessageStatus": "failed"})
|
||||||
self.assertEqual(r.status_code, 403)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
# The notification should not have the error field set:
|
||||||
|
self.n.refresh_from_db()
|
||||||
|
self.assertEqual(self.n.error, "")
|
||||||
|
|
||||||
def test_it_handles_missing_notification(self):
|
def test_it_handles_missing_notification(self):
|
||||||
fake_code = "07c2f548-9850-4b27-af5d-6c9dc157ec02"
|
fake_code = "07c2f548-9850-4b27-af5d-6c9dc157ec02"
|
||||||
|
@ -422,10 +422,11 @@ def notification_status(request, code):
|
|||||||
|
|
||||||
notification = get_object_or_404(Notification, code=code)
|
notification = get_object_or_404(Notification, code=code)
|
||||||
|
|
||||||
# If webhook is more than 1 hour late, don't accept it:
|
|
||||||
td = timezone.now() - notification.created
|
td = timezone.now() - notification.created
|
||||||
if td.total_seconds() > 3600:
|
if td.total_seconds() > 3600:
|
||||||
return HttpResponseForbidden()
|
# If the webhook is called more than 1 hour after the notification, ignore it.
|
||||||
|
# Return HTTP 200 so the other party doesn't retry over and over again:
|
||||||
|
return HttpResponse()
|
||||||
|
|
||||||
error, mark_not_verified = None, False
|
error, mark_not_verified = None, False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user