Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comments webhook panic #12046

Merged
merged 3 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/webhook/dingtalk.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ func GetDingtalkPayload(p api.Payloader, event models.HookEventType, meta string
case models.HookEventIssues, models.HookEventIssueAssign, models.HookEventIssueLabel, models.HookEventIssueMilestone:
return getDingtalkIssuesPayload(p.(*api.IssuePayload))
case models.HookEventIssueComment, models.HookEventPullRequestComment:
return getDingtalkIssueCommentPayload(p.(*api.IssueCommentPayload))
pl, ok := p.(*api.IssueCommentPayload)
if ok {
return getDingtalkIssueCommentPayload(pl)
}
return getDingtalkPullRequestPayload(p.(*api.PullRequestPayload))
case models.HookEventPush:
return getDingtalkPushPayload(p.(*api.PushPayload))
case models.HookEventPullRequest, models.HookEventPullRequestAssign, models.HookEventPullRequestLabel,
Expand Down
6 changes: 5 additions & 1 deletion modules/webhook/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ func GetDiscordPayload(p api.Payloader, event models.HookEventType, meta string)
case models.HookEventIssues, models.HookEventIssueAssign, models.HookEventIssueLabel, models.HookEventIssueMilestone:
return getDiscordIssuesPayload(p.(*api.IssuePayload), discord)
case models.HookEventIssueComment, models.HookEventPullRequestComment:
return getDiscordIssueCommentPayload(p.(*api.IssueCommentPayload), discord)
pl, ok := p.(*api.IssueCommentPayload)
if ok {
return getDiscordIssueCommentPayload(pl, discord)
}
return getDiscordPullRequestPayload(p.(*api.PullRequestPayload), discord)
case models.HookEventPush:
return getDiscordPushPayload(p.(*api.PushPayload), discord)
case models.HookEventPullRequest, models.HookEventPullRequestAssign, models.HookEventPullRequestLabel,
Expand Down
10 changes: 7 additions & 3 deletions modules/webhook/feishu.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,17 @@ func GetFeishuPayload(p api.Payloader, event models.HookEventType, meta string)
return getFeishuForkPayload(p.(*api.ForkPayload))
case models.HookEventIssues:
return getFeishuIssuesPayload(p.(*api.IssuePayload))
case models.HookEventIssueComment:
return getFeishuIssueCommentPayload(p.(*api.IssueCommentPayload))
case models.HookEventIssueComment, models.HookEventPullRequestComment:
pl, ok := p.(*api.IssueCommentPayload)
if ok {
return getFeishuIssueCommentPayload(pl)
}
return getFeishuPullRequestPayload(p.(*api.PullRequestPayload))
case models.HookEventPush:
return getFeishuPushPayload(p.(*api.PushPayload))
case models.HookEventPullRequest:
return getFeishuPullRequestPayload(p.(*api.PullRequestPayload))
case models.HookEventPullRequestReviewApproved, models.HookEventPullRequestReviewRejected, models.HookEventPullRequestComment:
case models.HookEventPullRequestReviewApproved, models.HookEventPullRequestReviewRejected:
return getFeishuPullRequestApprovalPayload(p.(*api.PullRequestPayload), event)
case models.HookEventRepository:
return getFeishuRepositoryPayload(p.(*api.RepositoryPayload))
Expand Down
2 changes: 2 additions & 0 deletions modules/webhook/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ func getPullRequestPayloadInfo(p *api.PullRequestPayload, linkFormatter linkForm
linkFormatter(mileStoneLink, p.PullRequest.Milestone.Title), titleLink)
case api.HookIssueDemilestoned:
text = fmt.Sprintf("[%s] Pull request milestone cleared: %s", repoLink, titleLink)
case api.HookIssueReviewed:
text = fmt.Sprintf("[%s] Pull request reviewed: %s", repoLink, titleLink)
}
if withSender {
text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName))
Expand Down
6 changes: 5 additions & 1 deletion modules/webhook/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ func GetMatrixPayload(p api.Payloader, event models.HookEventType, meta string)
case models.HookEventIssues, models.HookEventIssueAssign, models.HookEventIssueLabel, models.HookEventIssueMilestone:
return getMatrixIssuesPayload(p.(*api.IssuePayload), matrix)
case models.HookEventIssueComment, models.HookEventPullRequestComment:
return getMatrixIssueCommentPayload(p.(*api.IssueCommentPayload), matrix)
pl, ok := p.(*api.IssueCommentPayload)
if ok {
return getMatrixIssueCommentPayload(pl, matrix)
}
return getMatrixPullRequestPayload(p.(*api.PullRequestPayload), matrix)
case models.HookEventPush:
return getMatrixPushPayload(p.(*api.PushPayload), matrix)
case models.HookEventPullRequest, models.HookEventPullRequestAssign, models.HookEventPullRequestLabel,
Expand Down
6 changes: 5 additions & 1 deletion modules/webhook/msteams.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,11 @@ func GetMSTeamsPayload(p api.Payloader, event models.HookEventType, meta string)
case models.HookEventIssues, models.HookEventIssueAssign, models.HookEventIssueLabel, models.HookEventIssueMilestone:
return getMSTeamsIssuesPayload(p.(*api.IssuePayload))
case models.HookEventIssueComment, models.HookEventPullRequestComment:
return getMSTeamsIssueCommentPayload(p.(*api.IssueCommentPayload))
pl, ok := p.(*api.IssueCommentPayload)
if ok {
return getMSTeamsIssueCommentPayload(pl)
}
return getMSTeamsPullRequestPayload(p.(*api.PullRequestPayload))
case models.HookEventPush:
return getMSTeamsPushPayload(p.(*api.PushPayload))
case models.HookEventPullRequest, models.HookEventPullRequestAssign, models.HookEventPullRequestLabel,
Expand Down
6 changes: 5 additions & 1 deletion modules/webhook/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,11 @@ func GetSlackPayload(p api.Payloader, event models.HookEventType, meta string) (
case models.HookEventIssues, models.HookEventIssueAssign, models.HookEventIssueLabel, models.HookEventIssueMilestone:
return getSlackIssuesPayload(p.(*api.IssuePayload), slack)
case models.HookEventIssueComment, models.HookEventPullRequestComment:
return getSlackIssueCommentPayload(p.(*api.IssueCommentPayload), slack)
pl, ok := p.(*api.IssueCommentPayload)
if ok {
return getSlackIssueCommentPayload(pl, slack)
}
return getSlackPullRequestPayload(p.(*api.PullRequestPayload), slack)
case models.HookEventPush:
return getSlackPushPayload(p.(*api.PushPayload), slack)
case models.HookEventPullRequest, models.HookEventPullRequestAssign, models.HookEventPullRequestLabel,
Expand Down
6 changes: 5 additions & 1 deletion modules/webhook/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ func GetTelegramPayload(p api.Payloader, event models.HookEventType, meta string
case models.HookEventIssues, models.HookEventIssueAssign, models.HookEventIssueLabel, models.HookEventIssueMilestone:
return getTelegramIssuesPayload(p.(*api.IssuePayload))
case models.HookEventIssueComment, models.HookEventPullRequestComment:
return getTelegramIssueCommentPayload(p.(*api.IssueCommentPayload))
pl, ok := p.(*api.IssueCommentPayload)
if ok {
return getTelegramIssueCommentPayload(pl)
}
return getTelegramPullRequestPayload(p.(*api.PullRequestPayload))
case models.HookEventPush:
return getTelegramPushPayload(p.(*api.PushPayload))
case models.HookEventPullRequest, models.HookEventPullRequestAssign, models.HookEventPullRequestLabel,
Expand Down