forked from GithubBackups/healthchecks
Disable channel (mark as email_verified=False) when email bounces.
This commit is contained in:
parent
f2a2241b6b
commit
ddd940688e
@ -14,6 +14,7 @@ class BounceTestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.channel = Channel(user=self.alice, kind="email")
|
self.channel = Channel(user=self.alice, kind="email")
|
||||||
self.channel.value = "alice@example.org"
|
self.channel.value = "alice@example.org"
|
||||||
|
self.channel.email_verified = True
|
||||||
self.channel.save()
|
self.channel.save()
|
||||||
|
|
||||||
self.n = Notification(owner=self.check, channel=self.channel)
|
self.n = Notification(owner=self.check, channel=self.channel)
|
||||||
@ -27,6 +28,9 @@ class BounceTestCase(BaseTestCase):
|
|||||||
self.n.refresh_from_db()
|
self.n.refresh_from_db()
|
||||||
self.assertEqual(self.n.error, "foo")
|
self.assertEqual(self.n.error, "foo")
|
||||||
|
|
||||||
|
self.channel.refresh_from_db()
|
||||||
|
self.assertFalse(self.channel.email_verified)
|
||||||
|
|
||||||
def test_it_checks_ttl(self):
|
def test_it_checks_ttl(self):
|
||||||
self.n.created = self.n.created - timedelta(minutes=60)
|
self.n.created = self.n.created - timedelta(minutes=60)
|
||||||
self.n.save()
|
self.n.save()
|
||||||
|
@ -200,6 +200,9 @@ def bounce(request, code):
|
|||||||
notification.error = request.body[:200]
|
notification.error = request.body[:200]
|
||||||
notification.save()
|
notification.save()
|
||||||
|
|
||||||
|
notification.channel.email_verified = False
|
||||||
|
notification.channel.save()
|
||||||
|
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from hc.api.models import Channel
|
from hc.api.models import Check, Channel, Notification
|
||||||
from hc.test import BaseTestCase
|
from hc.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
@ -47,3 +47,29 @@ class ChannelsTestCase(BaseTestCase):
|
|||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
self.assertContains(r, "fake-key")
|
self.assertContains(r, "fake-key")
|
||||||
self.assertContains(r, "(normal priority)")
|
self.assertContains(r, "(normal priority)")
|
||||||
|
|
||||||
|
def test_it_shows_disabled_email(self):
|
||||||
|
check = Check(user=self.alice, status="up")
|
||||||
|
check.save()
|
||||||
|
|
||||||
|
channel = Channel(user=self.alice, kind="email")
|
||||||
|
channel.value = "alice@example.org"
|
||||||
|
channel.save()
|
||||||
|
|
||||||
|
n = Notification(owner=check, channel=channel, error="Invalid address")
|
||||||
|
n.save()
|
||||||
|
|
||||||
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
r = self.client.get("/integrations/")
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertContains(r, "(bounced, disabled)")
|
||||||
|
|
||||||
|
def test_it_shows_unconfirmed_email(self):
|
||||||
|
channel = Channel(user=self.alice, kind="email")
|
||||||
|
channel.value = "alice@example.org"
|
||||||
|
channel.save()
|
||||||
|
|
||||||
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
r = self.client.get("/integrations/")
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertContains(r, "(unconfirmed)")
|
||||||
|
@ -54,6 +54,11 @@ table.channels-table > tbody > tr > th {
|
|||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel-disabled {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.channels-help-hidden {
|
.channels-help-hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,16 @@
|
|||||||
<span class="preposition">to</span>
|
<span class="preposition">to</span>
|
||||||
{{ ch.value }}
|
{{ ch.value }}
|
||||||
{% if not ch.email_verified %}
|
{% if not ch.email_verified %}
|
||||||
<span class="channel-unconfirmed">(unconfirmed)</span>
|
{% if ch.latest_notification and ch.latest_notification.error %}
|
||||||
|
<span class="channel-disabled">
|
||||||
|
(bounced, disabled)
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="channel-unconfirmed">
|
||||||
|
(unconfirmed)
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif ch.kind == "pd" %}
|
{% elif ch.kind == "pd" %}
|
||||||
{% if ch.pd_account %}
|
{% if ch.pd_account %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user