Skip to content

Commit f737355

Browse files
committed
fix but when mentioning a slack user in summary
1 parent ce7e460 commit f737355

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/robusta/integrations/slack/sender.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import ssl
44
import tempfile
5+
import re
56
from datetime import datetime, timedelta
67
from itertools import chain
78
from typing import Any, Dict, List, Optional, Set
@@ -52,6 +53,7 @@
5253
ACTION_LINK = "link"
5354
SlackBlock = Dict[str, Any]
5455
MAX_BLOCK_CHARS = 3000
56+
MENTION_PATTERN = re.compile(r"<[^>]+>")
5557

5658

5759
class SlackSender:
@@ -410,8 +412,12 @@ def __create_holmes_callback(self, finding: Finding) -> CallbackBlock:
410412
def __create_finding_header(
411413
self, finding: Finding, status: FindingStatus, platform_enabled: bool, include_investigate_link: bool
412414
) -> MarkdownBlock:
413-
title = (finding.title.removeprefix("[RESOLVED] ")
414-
.replace("<", "&lt;").replace(">", "&gt;"))
415+
title = finding.title.removeprefix("[RESOLVED] ")
416+
417+
match = MENTION_PATTERN.search(title)
418+
mention = f" {match.group(0)}" if match else ""
419+
title = MENTION_PATTERN.sub("", title).strip()
420+
415421
sev = finding.severity
416422
if finding.source == FindingSource.PROMETHEUS:
417423
status_name: str = (
@@ -427,7 +433,7 @@ def __create_finding_header(
427433
title = f"<{finding.get_investigate_uri(self.account_id, self.cluster_name)}|*{title}*>"
428434
return MarkdownBlock(
429435
f"""{status_name} {sev.to_emoji()} *{sev.name.capitalize()}*
430-
{title}"""
436+
{title}{mention}"""
431437
)
432438

433439
def __create_links(

0 commit comments

Comments
 (0)