@@ -296,24 +296,39 @@ func (m *webhookNotifier) NewIssue(ctx context.Context, issue *issues_model.Issu
296296}
297297
298298func (m * webhookNotifier ) DeleteIssue (ctx context.Context , doer * user_model.User , issue * issues_model.Issue ) {
299- if err := issue .LoadRepo (ctx ); err != nil {
300- log .Error ("issue.LoadRepo: %v" , err )
301- return
302- }
303- if err := issue .LoadPoster (ctx ); err != nil {
304- log .Error ("issue.LoadPoster: %v" , err )
305- return
306- }
307-
308299 permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , doer )
309- if err := PrepareWebhooks (ctx , EventSource {Repository : issue .Repo }, webhook_module .HookEventIssues , & api.IssuePayload {
310- Action : api .HookIssueDeleted ,
311- Index : issue .Index ,
312- Issue : convert .ToAPIIssue (ctx , issue .Poster , issue ),
313- Repository : convert .ToRepo (ctx , issue .Repo , permission ),
314- Sender : convert .ToUser (ctx , doer , nil ),
315- }); err != nil {
316- log .Error ("PrepareWebhooks: %v" , err )
300+ if issue .IsPull {
301+ if err := issue .LoadPullRequest (ctx ); err != nil {
302+ log .Error ("LoadPullRequest: %v" , err )
303+ return
304+ }
305+ if err := PrepareWebhooks (ctx , EventSource {Repository : issue .Repo }, webhook_module .HookEventPullRequest , & api.PullRequestPayload {
306+ Action : api .HookIssueDeleted ,
307+ Index : issue .Index ,
308+ PullRequest : convert .ToAPIPullRequest (ctx , issue .PullRequest , doer ),
309+ Repository : convert .ToRepo (ctx , issue .Repo , permission ),
310+ Sender : convert .ToUser (ctx , doer , nil ),
311+ }); err != nil {
312+ log .Error ("PrepareWebhooks: %v" , err )
313+ }
314+ } else {
315+ if err := issue .LoadRepo (ctx ); err != nil {
316+ log .Error ("issue.LoadRepo: %v" , err )
317+ return
318+ }
319+ if err := issue .LoadPoster (ctx ); err != nil {
320+ log .Error ("issue.LoadPoster: %v" , err )
321+ return
322+ }
323+ if err := PrepareWebhooks (ctx , EventSource {Repository : issue .Repo }, webhook_module .HookEventIssues , & api.IssuePayload {
324+ Action : api .HookIssueDeleted ,
325+ Index : issue .Index ,
326+ Issue : convert .ToAPIIssue (ctx , issue .Poster , issue ),
327+ Repository : convert .ToRepo (ctx , issue .Repo , permission ),
328+ Sender : convert .ToUser (ctx , doer , nil ),
329+ }); err != nil {
330+ log .Error ("PrepareWebhooks: %v" , err )
331+ }
317332 }
318333}
319334
0 commit comments