From 5bc068451fe2860bda140a24ebcd458e6e91fed1 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Tue, 16 Apr 2024 07:35:58 -0600 Subject: [PATCH] find Author from slack --- slack.go | 4 ++++ slack_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/slack.go b/slack.go index e249dc4..8e081bd 100644 --- a/slack.go +++ b/slack.go @@ -98,6 +98,7 @@ type ( Asset string Resolved bool Datacenter string + Author string } slackMessage struct { @@ -118,6 +119,7 @@ type ( ParentID string `json:"thread_ts"` Text string Blocks []slackBlock + User string // bot Bot slackBot `json:"bot_profile"` Attachments []slackAttachment @@ -188,6 +190,7 @@ func parseSlack(b []byte) (parsedSlackMessage, error) { Asset: s.Event.Attachments[0].Text, Resolved: !strings.HasPrefix(s.Event.Attachments[0].Color, "F"), Datacenter: tagsField, + Author: s.Event.Bot.Name, }, nil } @@ -205,6 +208,7 @@ func parseSlack(b []byte) (parsedSlackMessage, error) { Plaintext: s.Event.Text, Asset: "", Datacenter: "", + Author: s.Event.User, }, nil } diff --git a/slack_test.go b/slack_test.go index 261e66d..bff4d8a 100644 --- a/slack_test.go +++ b/slack_test.go @@ -129,6 +129,7 @@ func TestParseSlackTestdata(t *testing.T) { Event: "", Plaintext: "I gotta do this", Asset: "", + Author: "U06868T6ADV", }, }, "opsgenie_alert.json": { @@ -164,6 +165,7 @@ func TestParseSlackTestdata(t *testing.T) { Plaintext: "At least one alertconfig run has failed unexpectedly.\nDashboard: \nPanel: \nSource: ", Asset: "At least one alertconfig run has failed unexpectedly.\nDashboard: \nPanel: \nSource: ", Datacenter: "alertname:Alertconfig Workflow Failed, grafana_folder:Datastores, rule_uid:a7639f7e-6950-41be-850a-b22119f74cbb", + Author: "Opsgenie for Alert Management", }, }, "opsgenie_alert_resolved.json": { @@ -200,6 +202,7 @@ func TestParseSlackTestdata(t *testing.T) { Asset: "At least one alertconfig run has failed unexpectedly.\nDashboard: \nPanel: \nSource: ", Resolved: true, Datacenter: "alertname:Alertconfig Workflow Failed, grafana_folder:Datastores, rule_uid:a7639f7e-6950-41be-850a-b22119f74cbb", + Author: "Opsgenie for Alert Management", }, }, "reingested_alert.json": { @@ -215,6 +218,7 @@ func TestParseSlackTestdata(t *testing.T) { Asset: "At least one alertconfig run has failed unexpectedly.\nDashboard: \nPanel: \nSource: ", Resolved: true, Datacenter: "alertname:Alertconfig Workflow Failed, grafana_folder:Datastores, rule_uid:a7639f7e-6950-41be-850a-b22119f74cbb", + Author: "Opsgenie for Alert Management", }, }, }