forked from GithubBackups/healthchecks
Don't log delivery notifications for unverified email addresses.
This commit is contained in:
parent
ddd940688e
commit
363f219671
@ -162,9 +162,9 @@ class NotifyTestCase(BaseTestCase):
|
|||||||
self._setup_data("email", "alice@example.org", email_verified=False)
|
self._setup_data("email", "alice@example.org", email_verified=False)
|
||||||
self.channel.notify(self.check)
|
self.channel.notify(self.check)
|
||||||
|
|
||||||
assert Notification.objects.count() == 1
|
# If an email is not verified, it should be skipped over
|
||||||
n = Notification.objects.first()
|
# without logging a notification:
|
||||||
self.assertEqual(n.error, "Email not verified")
|
self.assertEqual(Notification.objects.count(), 0)
|
||||||
self.assertEqual(len(mail.outbox), 0)
|
self.assertEqual(len(mail.outbox), 0)
|
||||||
|
|
||||||
@patch("hc.api.transports.requests.request")
|
@patch("hc.api.transports.requests.request")
|
||||||
|
@ -70,6 +70,9 @@ class Email(Transport):
|
|||||||
|
|
||||||
emails.alert(self.channel.value, ctx, headers)
|
emails.alert(self.channel.value, ctx, headers)
|
||||||
|
|
||||||
|
def is_noop(self, check):
|
||||||
|
return not self.channel.email_verified
|
||||||
|
|
||||||
|
|
||||||
class HttpTransport(Transport):
|
class HttpTransport(Transport):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user