From 70157e448f8424a2a4371828b4deba6722535641 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Mon, 20 Jan 2020 23:06:18 -0600 Subject: [PATCH 1/3] Fix RocketChat?? Signed-off-by: jolheiser --- modules/webhook/slack.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/webhook/slack.go b/modules/webhook/slack.go index 74361509d893f..a1e108f2049fd 100644 --- a/modules/webhook/slack.go +++ b/modules/webhook/slack.go @@ -233,6 +233,8 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e IconURL: slack.IconURL, Attachments: []SlackAttachment{{ Color: slack.Color, + Title: p.Repo.HTMLURL, + TitleLink: p.Repo.HTMLURL, Text: attachmentText, }}, }, nil From 1bf0cdc95f7d29d61a0dad63b44a0286b28bb586 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Mon, 20 Jan 2020 23:38:02 -0600 Subject: [PATCH 2/3] Don't send attachment for repo create/delete Signed-off-by: jolheiser --- modules/webhook/slack.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/webhook/slack.go b/modules/webhook/slack.go index a1e108f2049fd..12b55a936e63d 100644 --- a/modules/webhook/slack.go +++ b/modules/webhook/slack.go @@ -291,12 +291,11 @@ func getSlackPullRequestApprovalPayload(p *api.PullRequestPayload, slack *SlackM func getSlackRepositoryPayload(p *api.RepositoryPayload, slack *SlackMeta) (*SlackPayload, error) { senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName) repoLink := SlackLinkFormatter(p.Repository.HTMLURL, p.Repository.FullName) - var text, title, attachmentText string + var text string switch p.Action { case api.HookRepoCreated: text = fmt.Sprintf("[%s] Repository created by %s", repoLink, senderLink) - title = p.Repository.HTMLURL case api.HookRepoDeleted: text = fmt.Sprintf("[%s] Repository deleted by %s", repoLink, senderLink) } @@ -306,12 +305,6 @@ func getSlackRepositoryPayload(p *api.RepositoryPayload, slack *SlackMeta) (*Sla Text: text, Username: slack.Username, IconURL: slack.IconURL, - Attachments: []SlackAttachment{{ - Color: slack.Color, - Title: title, - TitleLink: title, - Text: attachmentText, - }}, }, nil } From 5642697ffd76291355fb1850db31c815de872f43 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Mon, 20 Jan 2020 23:53:01 -0600 Subject: [PATCH 3/3] Make fmt Signed-off-by: jolheiser --- modules/webhook/slack.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/webhook/slack.go b/modules/webhook/slack.go index 12b55a936e63d..361e15ece58fa 100644 --- a/modules/webhook/slack.go +++ b/modules/webhook/slack.go @@ -232,10 +232,10 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e Username: slack.Username, IconURL: slack.IconURL, Attachments: []SlackAttachment{{ - Color: slack.Color, - Title: p.Repo.HTMLURL, + Color: slack.Color, + Title: p.Repo.HTMLURL, TitleLink: p.Repo.HTMLURL, - Text: attachmentText, + Text: attachmentText, }}, }, nil }