mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-08 14:40:05 +00:00
parent
95e939785b
commit
bd7f658421
3 changed files with 47 additions and 14 deletions
|
@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Add support for Signal usernames
|
||||
- Update the "Currently running, started ... ago" template to use seconds precision
|
||||
- Implement S3 outage mitigation (don't attempt GetObject calls if many recent errors)
|
||||
- Add last ping body in MS Teams Workflows notifications (#1024)
|
||||
|
||||
### Bug Fixes
|
||||
- Fix incorrect status value in Webhook integration's $JSON placeholder
|
||||
|
|
|
@ -188,3 +188,17 @@ class NotifyMsTeamsTestCase(BaseTestCase):
|
|||
payload = mock_post.call_args.kwargs["json"]
|
||||
facts = self.facts(payload)
|
||||
self.assertEqual(facts["Last Ping:"], "Ignored, 10 minutes ago")
|
||||
|
||||
@patch("hc.api.transports.curl.request", autospec=True)
|
||||
def test_it_shows_last_ping_body(self, mock_post: Mock) -> None:
|
||||
mock_post.return_value.status_code = 200
|
||||
|
||||
self.ping.body_raw = b"Hello World"
|
||||
self.ping.save()
|
||||
|
||||
self.channel.notify(self.flip)
|
||||
|
||||
payload = mock_post.call_args.kwargs["json"]
|
||||
blocks = payload["attachments"][0]["content"]["body"]
|
||||
self.assertEqual(blocks[-1]["type"], "CodeBlock")
|
||||
self.assertEqual(blocks[-1]["codeSnippet"], "Hello World")
|
||||
|
|
|
@ -1237,6 +1237,21 @@ class MsTeamsWorkflow(HttpTransport):
|
|||
}
|
||||
text = tmpl("msteamsw_message.html", **ctx)
|
||||
|
||||
blocks: JSONList = [
|
||||
{
|
||||
"type": "TextBlock",
|
||||
"text": text,
|
||||
"weight": "bolder",
|
||||
"size": "medium",
|
||||
"wrap": True,
|
||||
"style": "heading",
|
||||
},
|
||||
{
|
||||
"type": "FactSet",
|
||||
"facts": fields,
|
||||
},
|
||||
]
|
||||
|
||||
result: JSONDict = {
|
||||
"type": "message",
|
||||
"attachments": [
|
||||
|
@ -1248,20 +1263,7 @@ class MsTeamsWorkflow(HttpTransport):
|
|||
"type": "AdaptiveCard",
|
||||
"fallbackText": f"“{escape(name)}” is {flip.new_status.upper()}.",
|
||||
"version": "1.2",
|
||||
"body": [
|
||||
{
|
||||
"type": "TextBlock",
|
||||
"text": text,
|
||||
"weight": "bolder",
|
||||
"size": "medium",
|
||||
"wrap": True,
|
||||
"style": "heading",
|
||||
},
|
||||
{
|
||||
"type": "FactSet",
|
||||
"facts": fields,
|
||||
},
|
||||
],
|
||||
"body": blocks,
|
||||
"actions": [
|
||||
{
|
||||
"type": "Action.OpenUrl",
|
||||
|
@ -1298,6 +1300,22 @@ class MsTeamsWorkflow(HttpTransport):
|
|||
fields.add("Total Pings:", "0")
|
||||
fields.add("Last Ping:", "Never")
|
||||
|
||||
if body := get_ping_body(ping, maxlen=1000):
|
||||
blocks.append(
|
||||
{
|
||||
"type": "TextBlock",
|
||||
"text": "Last Ping Body:",
|
||||
"weight": "bolder",
|
||||
}
|
||||
)
|
||||
blocks.append(
|
||||
{
|
||||
"type": "CodeBlock",
|
||||
"codeSnippet": body,
|
||||
"language": "PlainText",
|
||||
}
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
def notify(self, flip: Flip, notification: Notification) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue