Skip to content

Commit 834d38a

Browse files
committed
gogs#2045 add short version as fallback to Slack payload
1 parent 5572884 commit 834d38a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

models/webhook_slack.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ type SlackPayload struct {
3333
}
3434

3535
type SlackAttachment struct {
36-
Color string `json:"color"`
37-
Text string `json:"text"`
36+
Fallback string `json:"fallback"`
37+
Color string `json:"color"`
38+
Text string `json:"text"`
3839
}
3940

4041
func (p *SlackPayload) SetSecret(_ string) {}
@@ -111,7 +112,12 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e
111112
}
112113
}
113114

114-
slackAttachments := []SlackAttachment{{Color: slack.Color, Text: attachmentText}}
115+
slackAttachments := []SlackAttachment{{
116+
Fallback: fmt.Sprintf("%s pushed %s to %s/%s: %s",
117+
p.Pusher, commitString, p.Repo.Name, branchName, p.CompareUrl),
118+
Color: slack.Color,
119+
Text: attachmentText,
120+
}}
115121

116122
return &SlackPayload{
117123
Channel: slack.Channel,

0 commit comments

Comments
 (0)