Skip to content

Commit

Permalink
Updating slack's message
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgomide committed Apr 14, 2017
1 parent 8cc49e1 commit 1c65814
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hook/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package snitch

import "time"

type Hook interface {
CallHook(deploy []Deploy) error
SetWebHookURL(url string)
Expand All @@ -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)
}

0 comments on commit 1c65814

Please sign in to comment.