diff --git a/message.go b/message.go index 21c535f..4966eb0 100644 --- a/message.go +++ b/message.go @@ -2,8 +2,8 @@ package main import ( "encoding/json" + "errors" "fmt" - "strconv" "strings" ) @@ -99,8 +99,13 @@ func ParseSlack(b []byte) (Message, error) { } if s.Event.Bot.Name != "" { + if len(s.Event.Attachments) == 0 { + return Message{}, errors.New("bot message has no attachments") + } else if !strings.Contains(s.Event.Attachments[0].Title, ": Firing: ") { + return Message{}, errors.New("bot message attachment is not Firing") + } return Message{ - ID: strconv.FormatUint(s.TS, 10), + ID: fmt.Sprintf("%s/%v", s.Event.ID, s.TS), TS: s.TS, Source: fmt.Sprintf(`https://renderinc.slack.com/archives/%s/p%s`, s.Event.Channel, strings.ReplaceAll(s.Event.ID, ".", "")), Channel: s.Event.Channel, @@ -113,7 +118,7 @@ func ParseSlack(b []byte) (Message, error) { } return Message{ - ID: strconv.FormatUint(s.TS, 10), + ID: fmt.Sprintf("%s/%v", s.Event.ParentID, s.TS), TS: s.TS, Source: fmt.Sprintf(`https://renderinc.slack.com/archives/%s/p%s`, s.Event.Channel, strings.ReplaceAll(s.Event.ParentID, ".", "")), Channel: s.Event.Channel, diff --git a/message_test.go b/message_test.go index a73026a..2e302e8 100644 --- a/message_test.go +++ b/message_test.go @@ -34,7 +34,7 @@ func TestParseSlackTestdata(t *testing.T) { }, }, message: Message{ - ID: "1712930706", + ID: "1712927439.728409/1712930706", TS: 1712930706, Source: "https://renderinc.slack.com/archives/C06U1DDBBU4/p1712927439728409", Channel: "C06U1DDBBU4", @@ -68,7 +68,7 @@ func TestParseSlackTestdata(t *testing.T) { }, }, message: Message{ - ID: "1712927439", + ID: "1712927439.728409/1712927439", TS: 1712927439, Source: "https://renderinc.slack.com/archives/C06U1DDBBU4/p1712927439728409", Channel: "C06U1DDBBU4",