@@ -157,7 +157,6 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
157157 }
158158 } else {
159159 mode , _ := models .AccessLevelUnit (doer , issue .Repo , models .UnitTypeIssues )
160-
161160 apiIssue := & api.IssuePayload {
162161 Index : issue .Index ,
163162 Issue : issue .APIFormat (),
@@ -221,3 +220,45 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
221220 go models .HookQueue .Add (issue .RepoID )
222221 }
223222}
223+
224+ func (m * webhookNotifier ) NotifyIssueChangeStatus (doer * models.User , issue * models.Issue , isClosed bool ) {
225+ mode , _ := models .AccessLevel (issue .Poster , issue .Repo )
226+ var err error
227+ if issue .IsPull {
228+ if err = issue .LoadPullRequest (); err != nil {
229+ log .Error ("LoadPullRequest: %v" , err )
230+ return
231+ }
232+ // Merge pull request calls issue.changeStatus so we need to handle separately.
233+ apiPullRequest := & api.PullRequestPayload {
234+ Index : issue .Index ,
235+ PullRequest : issue .PullRequest .APIFormat (),
236+ Repository : issue .Repo .APIFormat (mode ),
237+ Sender : doer .APIFormat (),
238+ }
239+ if isClosed {
240+ apiPullRequest .Action = api .HookIssueClosed
241+ } else {
242+ apiPullRequest .Action = api .HookIssueReOpened
243+ }
244+ err = models .PrepareWebhooks (issue .Repo , models .HookEventPullRequest , apiPullRequest )
245+ } else {
246+ apiIssue := & api.IssuePayload {
247+ Index : issue .Index ,
248+ Issue : issue .APIFormat (),
249+ Repository : issue .Repo .APIFormat (mode ),
250+ Sender : doer .APIFormat (),
251+ }
252+ if isClosed {
253+ apiIssue .Action = api .HookIssueClosed
254+ } else {
255+ apiIssue .Action = api .HookIssueReOpened
256+ }
257+ err = models .PrepareWebhooks (issue .Repo , models .HookEventIssues , apiIssue )
258+ }
259+ if err != nil {
260+ log .Error ("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v" , issue .IsPull , isClosed , err )
261+ } else {
262+ go models .HookQueue .Add (issue .Repo .ID )
263+ }
264+ }
0 commit comments