Fix comments webhook panic (#12046)
* Fix webhook comment handling type cast panic * Handle HookIssueReviewed action in webhook Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
9ef2f62a79
commit
ebc35f2b2e
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue