summaryrefslogtreecommitdiffstats
path: root/models/webhook_slack.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-05-21 10:28:29 +0800
committerGitHub <noreply@github.com>2018-05-21 10:28:29 +0800
commit6bdc556b7f490be7360104b731ce817050cc1d80 (patch)
tree63887addb45b5b2be1e672580c984497fa9f4112 /models/webhook_slack.go
parentdc0ef38950ec8aca78f6e870fb83d1ca68074682 (diff)
downloadgitea-6bdc556b7f490be7360104b731ce817050cc1d80.tar.gz
gitea-6bdc556b7f490be7360104b731ce817050cc1d80.zip
Fix some webhooks bugs (#3981)
* fix some webhooks bugs * update vendor Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * fix test * fix clearlabels * fix pullrequest webhook bug fix #3492 * update release webhook description * remove unused code * fix push webhook in pull request * small changes
Diffstat (limited to 'models/webhook_slack.go')
-rw-r--r--models/webhook_slack.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/models/webhook_slack.go b/models/webhook_slack.go
index 7b18fe3278..23df17bf2c 100644
--- a/models/webhook_slack.go
+++ b/models/webhook_slack.go
@@ -213,7 +213,17 @@ func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (
func getSlackReleasePayload(p *api.ReleasePayload, slack *SlackMeta) (*SlackPayload, error) {
repoLink := SlackLinkFormatter(p.Repository.HTMLURL, p.Repository.Name)
refLink := SlackLinkFormatter(p.Repository.HTMLURL+"/src/"+p.Release.TagName, p.Release.TagName)
- text := fmt.Sprintf("[%s] new release %s published by %s", repoLink, refLink, p.Sender.UserName)
+ var text string
+
+ switch p.Action {
+ case api.HookReleasePublished:
+ text = fmt.Sprintf("[%s] new release %s published by %s", repoLink, refLink, p.Sender.UserName)
+ case api.HookReleaseUpdated:
+ text = fmt.Sprintf("[%s] new release %s updated by %s", repoLink, refLink, p.Sender.UserName)
+ case api.HookReleaseDeleted:
+ text = fmt.Sprintf("[%s] new release %s deleted by %s", repoLink, refLink, p.Sender.UserName)
+ }
+
return &SlackPayload{
Channel: slack.Channel,
Text: text,