mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
@@ -149,22 +149,22 @@ def slack_backend_send_alert(
|
|||||||
issue = Issue.objects.get(id=issue_id)
|
issue = Issue.objects.get(id=issue_id)
|
||||||
|
|
||||||
issue_url = get_settings().BASE_URL + issue.get_absolute_url()
|
issue_url = get_settings().BASE_URL + issue.get_absolute_url()
|
||||||
link = f"<{issue_url}|" + _safe_markdown(truncatechars(issue.title().replace("|", ""), 200)) + ">"
|
title = truncatechars(issue.title().replace("|", ""), 200)
|
||||||
|
link = f"<{issue_url}|view on Bugsink>"
|
||||||
|
|
||||||
sections = [
|
sections = [
|
||||||
{
|
{
|
||||||
"type": "header",
|
"type": "header",
|
||||||
"text": {
|
"text": {
|
||||||
"type": "plain_text",
|
"type": "plain_text",
|
||||||
# TODO arguably issue.title() should get this location; "later" because I don't have a test env.
|
"text": title,
|
||||||
"text": f"{alert_reason} issue",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "section",
|
"type": "section",
|
||||||
"text": {
|
"text": {
|
||||||
"type": "mrkdwn",
|
"type": "plain_text",
|
||||||
"text": link,
|
"text": f"{alert_reason} issue",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -191,18 +191,24 @@ def slack_backend_send_alert(
|
|||||||
# if event.environment:
|
# if event.environment:
|
||||||
# fields["environment"] = event.environment
|
# fields["environment"] = event.environment
|
||||||
|
|
||||||
data = {"text": sections[0]["text"]["text"], # mattermost requires at least one text field; use the first section
|
sections += [{"type": "section",
|
||||||
"blocks": sections + [
|
"fields": [
|
||||||
{
|
|
||||||
"type": "section",
|
|
||||||
"fields": [
|
|
||||||
{
|
{
|
||||||
"type": "mrkdwn",
|
"type": "mrkdwn",
|
||||||
"text": f"*{field}*: " + _safe_markdown(value),
|
"text": f"*{field}*: " + _safe_markdown(value),
|
||||||
} for field, value in fields.items()
|
} for field, value in fields.items()
|
||||||
]
|
]}]
|
||||||
},
|
|
||||||
]}
|
sections += [{
|
||||||
|
"type": "section",
|
||||||
|
"text": {
|
||||||
|
"type": "mrkdwn",
|
||||||
|
"text": link,
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
|
||||||
|
# slack service-backend also support mattermost; mattermost requires at least one text field; use the first section
|
||||||
|
data = {"text": sections[0]["text"]["text"], "blocks": sections}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = requests.post(
|
result = requests.post(
|
||||||
|
|||||||
Reference in New Issue
Block a user