diff --git a/hc/api/tests/test_bounce.py b/hc/api/tests/test_bounce.py index 9b51019a..f166b445 100644 --- a/hc/api/tests/test_bounce.py +++ b/hc/api/tests/test_bounce.py @@ -14,6 +14,7 @@ class BounceTestCase(BaseTestCase): self.channel = Channel(user=self.alice, kind="email") self.channel.value = "alice@example.org" + self.channel.email_verified = True self.channel.save() self.n = Notification(owner=self.check, channel=self.channel) @@ -27,6 +28,9 @@ class BounceTestCase(BaseTestCase): self.n.refresh_from_db() self.assertEqual(self.n.error, "foo") + self.channel.refresh_from_db() + self.assertFalse(self.channel.email_verified) + def test_it_checks_ttl(self): self.n.created = self.n.created - timedelta(minutes=60) self.n.save() diff --git a/hc/api/views.py b/hc/api/views.py index 6f18e853..9da65f36 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -200,6 +200,9 @@ def bounce(request, code): notification.error = request.body[:200] notification.save() + notification.channel.email_verified = False + notification.channel.save() + return HttpResponse() diff --git a/hc/front/tests/test_channels.py b/hc/front/tests/test_channels.py index ab194d30..f09a318f 100644 --- a/hc/front/tests/test_channels.py +++ b/hc/front/tests/test_channels.py @@ -1,6 +1,6 @@ import json -from hc.api.models import Channel +from hc.api.models import Check, Channel, Notification from hc.test import BaseTestCase @@ -47,3 +47,29 @@ class ChannelsTestCase(BaseTestCase): self.assertEqual(r.status_code, 200) self.assertContains(r, "fake-key") 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)") diff --git a/static/css/channels.css b/static/css/channels.css index 7f70960e..0d2a0d5c 100644 --- a/static/css/channels.css +++ b/static/css/channels.css @@ -54,6 +54,11 @@ table.channels-table > tbody > tr > th { font-size: small; } +.channel-disabled { + font-size: small; +} + + .channels-help-hidden { display: none; } diff --git a/templates/front/channels.html b/templates/front/channels.html index 946093ee..a9557679 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -32,7 +32,16 @@ to {{ ch.value }} {% if not ch.email_verified %} - (unconfirmed) + {% if ch.latest_notification and ch.latest_notification.error %} + + (bounced, disabled) + + {% else %} + + (unconfirmed) + + {% endif %} + {% endif %} {% elif ch.kind == "pd" %} {% if ch.pd_account %}