forked from GithubBackups/healthchecks
Add a "Subject" field in the "Ping Details" dialog
This commit is contained in:
parent
1bc89f0d5d
commit
2a63d24812
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
||||
## Improvements
|
||||
- Rename VictorOps -> Splunk On-Call
|
||||
- Implement email body decoding in the "Ping Details" dialog
|
||||
- Add a "Subject" field in the "Ping Details" dialog
|
||||
|
||||
## Bug Fixes
|
||||
- Fix downtime summary to handle months when the check didn't exist yet (#472)
|
||||
|
@ -142,3 +142,16 @@ class PingDetailsTestCase(BaseTestCase):
|
||||
# PGI+aGVsbG88L2I+ is base64("<b>hello</b>")
|
||||
self.assertContains(r, "PGI+aGVsbG88L2I+")
|
||||
self.assertContains(r, "<b>hello</b>")
|
||||
|
||||
def test_it_decodes_email_subject(self):
|
||||
Ping.objects.create(
|
||||
owner=self.check,
|
||||
scheme="email",
|
||||
body="Subject: =?UTF-8?B?aGVsbG8gd29ybGQ=?=",
|
||||
)
|
||||
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
r = self.client.get(self.url)
|
||||
|
||||
# aGVsbG8gd29ybGQ= is base64("hello world")
|
||||
self.assertContains(r, "hello world", status_code=200)
|
||||
|
@ -512,6 +512,7 @@ def ping_details(request, code, n=None):
|
||||
|
||||
if ping.scheme == "email":
|
||||
parsed = email.message_from_string(ping.body, policy=email.policy.SMTP)
|
||||
ctx["subject"] = parsed.get("subject", "")
|
||||
|
||||
plain_mime_part = parsed.get_body(("plain",))
|
||||
if plain_mime_part:
|
||||
|
@ -62,6 +62,15 @@
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if subject %}
|
||||
<div class="col-sm-12">
|
||||
<p>
|
||||
<strong>Subject</strong>
|
||||
<span>{{ subject }}</span>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if ping.body %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user