Skip to content

Commit d79a00d

Browse files
committed
Update sender.py
1 parent ef3214d commit d79a00d

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

src/robusta/integrations/slack/sender.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,7 @@ def send_finding_to_slack(
671671
if finding.description:
672672
# We'll put the description in the attachment rather than the main message
673673
description_text = finding.description
674-
if finding.source == FindingSource.PROMETHEUS:
675-
description_text = f"{Emojis.Alert.value} *Alert:* {description_text}"
676-
elif finding.source == FindingSource.KUBERNETES_API_SERVER:
677-
description_text = f"{Emojis.K8Notification.value} *K8s event detected:* {description_text}"
678-
else:
679-
description_text = f"{Emojis.K8Notification.value} *Notification:* {description_text}"
674+
# No prefixes, just the description itself
680675

681676
attachment_blocks.append(MarkdownBlock(description_text))
682677

@@ -702,9 +697,8 @@ def send_finding_to_slack(
702697

703698
# Add file blocks to the main blocks for proper handling
704699
blocks.extend(all_file_blocks)
705-
706-
if len(attachment_blocks):
707-
attachment_blocks.append(DividerBlock())
700+
701+
# No divider in the main blocks
708702

709703
# We need to create a minimal version of __send_blocks_to_slack
710704
# that can handle both our header blocks and regular blocks
@@ -740,15 +734,28 @@ def send_finding_to_slack(
740734
else:
741735
kwargs = {}
742736

743-
# Send the message with our JIRA-style headers and single color attachment
737+
# Create a single attachment with all blocks and a divider at the end
738+
attachments = []
739+
740+
# Add divider to the end of attachment blocks if there are any
741+
all_attachment_blocks = attachment_slack_blocks.copy() if attachment_slack_blocks else []
742+
743+
# Always add a divider at the end
744+
all_attachment_blocks.append({"type": "divider"})
745+
746+
# Create a single attachment with the status color
747+
attachments = [{
748+
"color": status.to_color_hex(),
749+
"blocks": all_attachment_blocks
750+
}]
751+
752+
# Send the message with our JIRA-style headers and attachments
744753
resp = self.slack_client.chat_postMessage(
745754
channel=slack_channel,
746755
text=message,
747756
blocks=all_blocks,
748757
display_as_bot=True,
749-
attachments=(
750-
[{"color": status.to_color_hex(), "blocks": attachment_slack_blocks}] if attachment_slack_blocks else None
751-
),
758+
attachments=attachments,
752759
unfurl_links=unfurl,
753760
unfurl_media=unfurl,
754761
**kwargs,

0 commit comments

Comments
 (0)