|
|
|
@ -370,11 +370,19 @@ func (issue *Issue) HasLabel(labelID int64) bool { |
|
|
|
|
|
|
|
|
|
func (issue *Issue) sendLabelUpdatedWebhook(doer *User) { |
|
|
|
|
var err error |
|
|
|
|
|
|
|
|
|
if err = issue.loadRepo(x); err != nil { |
|
|
|
|
log.Error(4, "loadRepo: %v", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err = issue.loadPoster(x); err != nil { |
|
|
|
|
log.Error(4, "loadPoster: %v", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
|
if issue.IsPull { |
|
|
|
|
if err = issue.loadRepo(x); err != nil { |
|
|
|
|
log.Error(4, "loadRepo: %v", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if err = issue.loadPullRequest(x); err != nil { |
|
|
|
|
log.Error(4, "loadPullRequest: %v", err) |
|
|
|
|
return |
|
|
|
@ -390,6 +398,14 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) { |
|
|
|
|
Repository: issue.Repo.APIFormat(AccessModeNone), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventIssues, &api.IssuePayload{ |
|
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
|
Index: issue.Index, |
|
|
|
|
Issue: issue.APIFormat(), |
|
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
|
|
|
@ -505,6 +521,11 @@ func (issue *Issue) ClearLabels(doer *User) (err error) { |
|
|
|
|
return fmt.Errorf("Commit: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err = issue.loadPoster(x); err != nil { |
|
|
|
|
return fmt.Errorf("loadPoster: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
|
if issue.IsPull { |
|
|
|
|
err = issue.PullRequest.LoadIssue() |
|
|
|
|
if err != nil { |
|
|
|
@ -515,9 +536,17 @@ func (issue *Issue) ClearLabels(doer *User) (err error) { |
|
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
|
Index: issue.Index, |
|
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
|
Repository: issue.Repo.APIFormat(AccessModeNone), |
|
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventIssues, &api.IssuePayload{ |
|
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
|
Index: issue.Index, |
|
|
|
|
Issue: issue.APIFormat(), |
|
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
|
|
|
@ -675,13 +704,14 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e |
|
|
|
|
return fmt.Errorf("Commit: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
|
if issue.IsPull { |
|
|
|
|
// Merge pull request calls issue.changeStatus so we need to handle separately.
|
|
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
|
Index: issue.Index, |
|
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
|
Repository: repo.APIFormat(AccessModeNone), |
|
|
|
|
Repository: repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
} |
|
|
|
|
if isClosed { |
|
|
|
@ -690,6 +720,19 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e |
|
|
|
|
apiPullRequest.Action = api.HookIssueReOpened |
|
|
|
|
} |
|
|
|
|
err = PrepareWebhooks(repo, HookEventPullRequest, apiPullRequest) |
|
|
|
|
} else { |
|
|
|
|
apiIssue := &api.IssuePayload{ |
|
|
|
|
Index: issue.Index, |
|
|
|
|
Issue: issue.APIFormat(), |
|
|
|
|
Repository: repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
} |
|
|
|
|
if isClosed { |
|
|
|
|
apiIssue.Action = api.HookIssueClosed |
|
|
|
|
} else { |
|
|
|
|
apiIssue.Action = api.HookIssueReOpened |
|
|
|
|
} |
|
|
|
|
err = PrepareWebhooks(repo, HookEventIssues, apiIssue) |
|
|
|
|
} |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err) |
|
|
|
@ -723,6 +766,7 @@ func (issue *Issue) ChangeTitle(doer *User, title string) (err error) { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
|
if issue.IsPull { |
|
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
@ -734,10 +778,24 @@ func (issue *Issue) ChangeTitle(doer *User, title string) (err error) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
|
Repository: issue.Repo.APIFormat(AccessModeNone), |
|
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventIssues, &api.IssuePayload{ |
|
|
|
|
Action: api.HookIssueEdited, |
|
|
|
|
Index: issue.Index, |
|
|
|
|
Changes: &api.ChangesPayload{ |
|
|
|
|
Title: &api.ChangesFromPayload{ |
|
|
|
|
From: oldTitle, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
Issue: issue.APIFormat(), |
|
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
|
Sender: issue.Poster.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
|
|
|
|
} else { |
|
|
|
@ -774,6 +832,7 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) { |
|
|
|
|
return fmt.Errorf("UpdateIssueCols: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
|
if issue.IsPull { |
|
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
@ -785,9 +844,22 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
|
Repository: issue.Repo.APIFormat(AccessModeNone), |
|
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventIssues, &api.IssuePayload{ |
|
|
|
|
Action: api.HookIssueEdited, |
|
|
|
|
Index: issue.Index, |
|
|
|
|
Changes: &api.ChangesPayload{ |
|
|
|
|
Body: &api.ChangesFromPayload{ |
|
|
|
|
From: oldContent, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
Issue: issue.APIFormat(), |
|
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
|
Sender: doer.APIFormat(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
|
|
|
@ -980,6 +1052,19 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, assigneeIDs []in |
|
|
|
|
log.Error(4, "MailParticipants: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
|
if err = PrepareWebhooks(repo, HookEventIssues, &api.IssuePayload{ |
|
|
|
|
Action: api.HookIssueOpened, |
|
|
|
|
Index: issue.Index, |
|
|
|
|
Issue: issue.APIFormat(), |
|
|
|
|
Repository: repo.APIFormat(mode), |
|
|
|
|
Sender: issue.Poster.APIFormat(), |
|
|
|
|
}); err != nil { |
|
|
|
|
log.Error(4, "PrepareWebhooks: %v", err) |
|
|
|
|
} else { |
|
|
|
|
go HookQueue.Add(issue.RepoID) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|