From 1707f59966df7fa4375235dbf43326d382eeaf97 Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Mon, 16 Dec 2019 18:28:19 -0600 Subject: [PATCH] Remove text from action-only webhooks (#9377) * Remove text from contextual webhooks Signed-off-by: jolheiser * Missed one in Telegram Signed-off-by: jolheiser --- modules/webhook/dingtalk.go | 18 ------------------ modules/webhook/discord.go | 18 ------------------ modules/webhook/msteams.go | 18 ------------------ modules/webhook/telegram.go | 18 ------------------ 4 files changed, 72 deletions(-) diff --git a/modules/webhook/dingtalk.go b/modules/webhook/dingtalk.go index b6d58f55cfe..5ec8db9649d 100644 --- a/modules/webhook/dingtalk.go +++ b/modules/webhook/dingtalk.go @@ -139,35 +139,26 @@ func getDingtalkIssuesPayload(p *api.IssuePayload) (*DingtalkPayload, error) { text = p.Issue.Body case api.HookIssueClosed: title = fmt.Sprintf("[%s] Issue closed: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueReOpened: title = fmt.Sprintf("[%s] Issue re-opened: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueEdited: title = fmt.Sprintf("[%s] Issue edited: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) text = p.Issue.Body case api.HookIssueAssigned: title = fmt.Sprintf("[%s] Issue assigned to %s: #%d %s", p.Repository.FullName, p.Issue.Assignee.UserName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueUnassigned: title = fmt.Sprintf("[%s] Issue unassigned: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueLabelUpdated: title = fmt.Sprintf("[%s] Issue labels updated: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueLabelCleared: title = fmt.Sprintf("[%s] Issue labels cleared: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueSynchronized: title = fmt.Sprintf("[%s] Issue synchronized: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueMilestoned: title = fmt.Sprintf("[%s] Issue milestone: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueDemilestoned: title = fmt.Sprintf("[%s] Issue clear milestone: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body } return &DingtalkPayload{ @@ -238,10 +229,8 @@ func getDingtalkPullRequestPayload(p *api.PullRequestPayload) (*DingtalkPayload, } else { title = fmt.Sprintf("[%s] Pull request closed: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) } - text = p.PullRequest.Body case api.HookIssueReOpened: title = fmt.Sprintf("[%s] Pull request re-opened: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueEdited: title = fmt.Sprintf("[%s] Pull request edited: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) text = p.PullRequest.Body @@ -253,25 +242,18 @@ func getDingtalkPullRequestPayload(p *api.PullRequestPayload) (*DingtalkPayload, title = fmt.Sprintf("[%s] Pull request assigned to %s: #%d %s", p.Repository.FullName, strings.Join(list, ", "), p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueUnassigned: title = fmt.Sprintf("[%s] Pull request unassigned: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueLabelUpdated: title = fmt.Sprintf("[%s] Pull request labels updated: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueLabelCleared: title = fmt.Sprintf("[%s] Pull request labels cleared: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueSynchronized: title = fmt.Sprintf("[%s] Pull request synchronized: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueMilestoned: title = fmt.Sprintf("[%s] Pull request milestone: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueDemilestoned: title = fmt.Sprintf("[%s] Pull request clear milestone: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body } return &DingtalkPayload{ diff --git a/modules/webhook/discord.go b/modules/webhook/discord.go index f92157a1ab4..99444851bc1 100644 --- a/modules/webhook/discord.go +++ b/modules/webhook/discord.go @@ -238,10 +238,8 @@ func getDiscordIssuesPayload(p *api.IssuePayload, meta *DiscordMeta) (*DiscordPa case api.HookIssueClosed: title = fmt.Sprintf("[%s] Issue closed: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) color = redColor - text = p.Issue.Body case api.HookIssueReOpened: title = fmt.Sprintf("[%s] Issue re-opened: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueEdited: title = fmt.Sprintf("[%s] Issue edited: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) @@ -250,31 +248,24 @@ func getDiscordIssuesPayload(p *api.IssuePayload, meta *DiscordMeta) (*DiscordPa case api.HookIssueAssigned: title = fmt.Sprintf("[%s] Issue assigned to %s: #%d %s", p.Repository.FullName, p.Issue.Assignee.UserName, p.Index, p.Issue.Title) - text = p.Issue.Body color = greenColor case api.HookIssueUnassigned: title = fmt.Sprintf("[%s] Issue unassigned: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueLabelUpdated: title = fmt.Sprintf("[%s] Issue labels updated: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueLabelCleared: title = fmt.Sprintf("[%s] Issue labels cleared: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueSynchronized: title = fmt.Sprintf("[%s] Issue synchronized: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueMilestoned: title = fmt.Sprintf("[%s] Issue milestone: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueDemilestoned: title = fmt.Sprintf("[%s] Issue clear milestone: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor } @@ -368,10 +359,8 @@ func getDiscordPullRequestPayload(p *api.PullRequestPayload, meta *DiscordMeta) title = fmt.Sprintf("[%s] Pull request closed: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) color = redColor } - text = p.PullRequest.Body case api.HookIssueReOpened: title = fmt.Sprintf("[%s] Pull request re-opened: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueEdited: title = fmt.Sprintf("[%s] Pull request edited: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) @@ -385,31 +374,24 @@ func getDiscordPullRequestPayload(p *api.PullRequestPayload, meta *DiscordMeta) title = fmt.Sprintf("[%s] Pull request assigned to %s: #%d by %s", p.Repository.FullName, strings.Join(list, ", "), p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = greenColor case api.HookIssueUnassigned: title = fmt.Sprintf("[%s] Pull request unassigned: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueLabelUpdated: title = fmt.Sprintf("[%s] Pull request labels updated: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueLabelCleared: title = fmt.Sprintf("[%s] Pull request labels cleared: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueSynchronized: title = fmt.Sprintf("[%s] Pull request synchronized: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueMilestoned: title = fmt.Sprintf("[%s] Pull request milestone: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueDemilestoned: title = fmt.Sprintf("[%s] Pull request clear milestone: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor } diff --git a/modules/webhook/msteams.go b/modules/webhook/msteams.go index 2636e299830..8ff9bb5ba45 100644 --- a/modules/webhook/msteams.go +++ b/modules/webhook/msteams.go @@ -277,10 +277,8 @@ func getMSTeamsIssuesPayload(p *api.IssuePayload) (*MSTeamsPayload, error) { case api.HookIssueClosed: title = fmt.Sprintf("[%s] Issue closed: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) color = redColor - text = p.Issue.Body case api.HookIssueReOpened: title = fmt.Sprintf("[%s] Issue re-opened: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueEdited: title = fmt.Sprintf("[%s] Issue edited: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) @@ -289,31 +287,24 @@ func getMSTeamsIssuesPayload(p *api.IssuePayload) (*MSTeamsPayload, error) { case api.HookIssueAssigned: title = fmt.Sprintf("[%s] Issue assigned to %s: #%d %s", p.Repository.FullName, p.Issue.Assignee.UserName, p.Index, p.Issue.Title) - text = p.Issue.Body color = greenColor case api.HookIssueUnassigned: title = fmt.Sprintf("[%s] Issue unassigned: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueLabelUpdated: title = fmt.Sprintf("[%s] Issue labels updated: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueLabelCleared: title = fmt.Sprintf("[%s] Issue labels cleared: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueSynchronized: title = fmt.Sprintf("[%s] Issue synchronized: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueMilestoned: title = fmt.Sprintf("[%s] Issue milestone: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor case api.HookIssueDemilestoned: title = fmt.Sprintf("[%s] Issue clear milestone: #%d %s", p.Repository.FullName, p.Index, p.Issue.Title) - text = p.Issue.Body color = yellowColor } @@ -447,10 +438,8 @@ func getMSTeamsPullRequestPayload(p *api.PullRequestPayload) (*MSTeamsPayload, e title = fmt.Sprintf("[%s] Pull request closed: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) color = redColor } - text = p.PullRequest.Body case api.HookIssueReOpened: title = fmt.Sprintf("[%s] Pull request re-opened: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueEdited: title = fmt.Sprintf("[%s] Pull request edited: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) @@ -464,31 +453,24 @@ func getMSTeamsPullRequestPayload(p *api.PullRequestPayload) (*MSTeamsPayload, e title = fmt.Sprintf("[%s] Pull request assigned to %s: #%d by %s", p.Repository.FullName, strings.Join(list, ", "), p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = greenColor case api.HookIssueUnassigned: title = fmt.Sprintf("[%s] Pull request unassigned: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueLabelUpdated: title = fmt.Sprintf("[%s] Pull request labels updated: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueLabelCleared: title = fmt.Sprintf("[%s] Pull request labels cleared: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueSynchronized: title = fmt.Sprintf("[%s] Pull request synchronized: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueMilestoned: title = fmt.Sprintf("[%s] Pull request milestone: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor case api.HookIssueDemilestoned: title = fmt.Sprintf("[%s] Pull request clear milestone: #%d %s", p.Repository.FullName, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body color = yellowColor } diff --git a/modules/webhook/telegram.go b/modules/webhook/telegram.go index 4e67b22954a..d95ee0f73fe 100644 --- a/modules/webhook/telegram.go +++ b/modules/webhook/telegram.go @@ -135,11 +135,9 @@ func getTelegramIssuesPayload(p *api.IssuePayload) (*TelegramPayload, error) { case api.HookIssueClosed: title = fmt.Sprintf(`[%s] Issue closed: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueReOpened: title = fmt.Sprintf(`[%s] Issue re-opened: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueEdited: title = fmt.Sprintf(`[%s] Issue edited: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) @@ -147,31 +145,24 @@ func getTelegramIssuesPayload(p *api.IssuePayload) (*TelegramPayload, error) { case api.HookIssueAssigned: title = fmt.Sprintf(`[%s] Issue assigned to %s: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.Assignee.UserName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueUnassigned: title = fmt.Sprintf(`[%s] Issue unassigned: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueLabelUpdated: title = fmt.Sprintf(`[%s] Issue labels updated: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueLabelCleared: title = fmt.Sprintf(`[%s] Issue labels cleared: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueSynchronized: title = fmt.Sprintf(`[%s] Issue synchronized: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueMilestoned: title = fmt.Sprintf(`[%s] Issue milestone: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body case api.HookIssueDemilestoned: title = fmt.Sprintf(`[%s] Issue clear milestone: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.Issue.URL, p.Index, p.Issue.Title) - text = p.Issue.Body } return &TelegramPayload{ @@ -215,11 +206,9 @@ func getTelegramPullRequestPayload(p *api.PullRequestPayload) (*TelegramPayload, title = fmt.Sprintf(`[%s] Pull request closed: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) } - text = p.PullRequest.Body case api.HookIssueReOpened: title = fmt.Sprintf(`[%s] Pull request re-opened: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueEdited: title = fmt.Sprintf(`[%s] Pull request edited: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) @@ -231,31 +220,24 @@ func getTelegramPullRequestPayload(p *api.PullRequestPayload) (*TelegramPayload, } title = fmt.Sprintf(`[%s] Pull request assigned to %s: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, list, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueUnassigned: title = fmt.Sprintf(`[%s] Pull request unassigned: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueLabelUpdated: title = fmt.Sprintf(`[%s] Pull request labels updated: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueLabelCleared: title = fmt.Sprintf(`[%s] Pull request labels cleared: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueSynchronized: title = fmt.Sprintf(`[%s] Pull request synchronized: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueMilestoned: title = fmt.Sprintf(`[%s] Pull request milestone: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body case api.HookIssueDemilestoned: title = fmt.Sprintf(`[%s] Pull request clear milestone: #%d %s`, p.Repository.HTMLURL, p.Repository.FullName, p.PullRequest.HTMLURL, p.Index, p.PullRequest.Title) - text = p.PullRequest.Body } return &TelegramPayload{