Skip to content

Commit 1c65814

Browse files
committed
Updating slack's message
1 parent 8cc49e1 commit 1c65814

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

hook/slack.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ type Slack struct {
1212
}
1313

1414
func (s *Slack) CallHook(deploy []snitch.Deploy) error {
15-
message := `"The application ` + deploy[0].App + ` has been deployed just now by ` + deploy[0].User + ` at ` + deploy[0].Timestamp + `"`
15+
message := `"The application *` + deploy[0].App + `* has been deployed just now by ` + deploy[0].User + ` at _` + deploy[0].ConvertTimestampToRFC822() + `_"`
16+
1617
data := []byte(`{"text":` + message + `}`)
1718
resp, err := http.Post(s.WebhookURL, "application/json", bytes.NewReader(data))
1819
if err != nil {

types/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package snitch
22

3+
import "time"
4+
35
type Hook interface {
46
CallHook(deploy []Deploy) error
57
SetWebHookURL(url string)
@@ -15,3 +17,8 @@ type Deploy struct {
1517
Commit string
1618
User string
1719
}
20+
21+
func (d Deploy) ConvertTimestampToRFC822() string {
22+
t, _ := time.Parse(time.RFC3339, d.Timestamp)
23+
return t.Format(time.RFC822)
24+
}

0 commit comments

Comments
 (0)