mirror of
https://github.com/bugsink/bugsink.git
synced 2025-12-30 01:40:08 -06:00
@@ -149,22 +149,22 @@ def slack_backend_send_alert(
|
||||
issue = Issue.objects.get(id=issue_id)
|
||||
|
||||
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 = [
|
||||
{
|
||||
"type": "header",
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
# TODO arguably issue.title() should get this location; "later" because I don't have a test env.
|
||||
"text": f"{alert_reason} issue",
|
||||
"text": title,
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": link,
|
||||
"type": "plain_text",
|
||||
"text": f"{alert_reason} issue",
|
||||
},
|
||||
},
|
||||
]
|
||||
@@ -191,18 +191,24 @@ def slack_backend_send_alert(
|
||||
# if event.environment:
|
||||
# fields["environment"] = event.environment
|
||||
|
||||
data = {"text": sections[0]["text"]["text"], # mattermost requires at least one text field; use the first section
|
||||
"blocks": sections + [
|
||||
{
|
||||
"type": "section",
|
||||
"fields": [
|
||||
sections += [{"type": "section",
|
||||
"fields": [
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": f"*{field}*: " + _safe_markdown(value),
|
||||
} 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:
|
||||
result = requests.post(
|
||||
|
||||
Reference in New Issue
Block a user