From 1c65814f29253226733af5b4f95a25fccaa995e5 Mon Sep 17 00:00:00 2001 From: lucasgomide Date: Fri, 14 Apr 2017 13:34:17 -0300 Subject: [PATCH] Updating slack's message --- hook/slack.go | 3 ++- types/types.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hook/slack.go b/hook/slack.go index 3dd3019..e15485c 100644 --- a/hook/slack.go +++ b/hook/slack.go @@ -12,7 +12,8 @@ type Slack struct { } func (s *Slack) CallHook(deploy []snitch.Deploy) error { - message := `"The application ` + deploy[0].App + ` has been deployed just now by ` + deploy[0].User + ` at ` + deploy[0].Timestamp + `"` + message := `"The application *` + deploy[0].App + `* has been deployed just now by ` + deploy[0].User + ` at _` + deploy[0].ConvertTimestampToRFC822() + `_"` + data := []byte(`{"text":` + message + `}`) resp, err := http.Post(s.WebhookURL, "application/json", bytes.NewReader(data)) if err != nil { diff --git a/types/types.go b/types/types.go index 44ff12c..15a943f 100644 --- a/types/types.go +++ b/types/types.go @@ -1,5 +1,7 @@ package snitch +import "time" + type Hook interface { CallHook(deploy []Deploy) error SetWebHookURL(url string) @@ -15,3 +17,8 @@ type Deploy struct { Commit string User string } + +func (d Deploy) ConvertTimestampToRFC822() string { + t, _ := time.Parse(time.RFC3339, d.Timestamp) + return t.Format(time.RFC822) +}