|
|
@ -370,11 +370,19 @@ func (issue *Issue) HasLabel(labelID int64) bool { |
|
|
|
|
|
|
|
|
|
|
|
func (issue *Issue) sendLabelUpdatedWebhook(doer *User) { |
|
|
|
func (issue *Issue) sendLabelUpdatedWebhook(doer *User) { |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if issue.IsPull { |
|
|
|
|
|
|
|
if err = issue.loadRepo(x); err != nil { |
|
|
|
if err = issue.loadRepo(x); err != nil { |
|
|
|
log.Error(4, "loadRepo: %v", err) |
|
|
|
log.Error(4, "loadRepo: %v", err) |
|
|
|
return |
|
|
|
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.loadPullRequest(x); err != nil { |
|
|
|
if err = issue.loadPullRequest(x); err != nil { |
|
|
|
log.Error(4, "loadPullRequest: %v", err) |
|
|
|
log.Error(4, "loadPullRequest: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -390,6 +398,14 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) { |
|
|
|
Repository: issue.Repo.APIFormat(AccessModeNone), |
|
|
|
Repository: issue.Repo.APIFormat(AccessModeNone), |
|
|
|
Sender: doer.APIFormat(), |
|
|
|
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 { |
|
|
|
if err != nil { |
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
|
|
|
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) |
|
|
|
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 { |
|
|
|
if issue.IsPull { |
|
|
|
err = issue.PullRequest.LoadIssue() |
|
|
|
err = issue.PullRequest.LoadIssue() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -515,7 +536,15 @@ func (issue *Issue) ClearLabels(doer *User) (err error) { |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
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(), |
|
|
|
Sender: doer.APIFormat(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -675,13 +704,14 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e |
|
|
|
return fmt.Errorf("Commit: %v", err) |
|
|
|
return fmt.Errorf("Commit: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
// Merge pull request calls issue.changeStatus so we need to handle separately.
|
|
|
|
// Merge pull request calls issue.changeStatus so we need to handle separately.
|
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
Repository: repo.APIFormat(AccessModeNone), |
|
|
|
Repository: repo.APIFormat(mode), |
|
|
|
Sender: doer.APIFormat(), |
|
|
|
Sender: doer.APIFormat(), |
|
|
|
} |
|
|
|
} |
|
|
|
if isClosed { |
|
|
|
if isClosed { |
|
|
@ -690,6 +720,19 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e |
|
|
|
apiPullRequest.Action = api.HookIssueReOpened |
|
|
|
apiPullRequest.Action = api.HookIssueReOpened |
|
|
|
} |
|
|
|
} |
|
|
|
err = PrepareWebhooks(repo, HookEventPullRequest, apiPullRequest) |
|
|
|
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 { |
|
|
|
if err != nil { |
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err) |
|
|
|
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 |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
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(), |
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
Repository: issue.Repo.APIFormat(AccessModeNone), |
|
|
|
Repository: issue.Repo.APIFormat(mode), |
|
|
|
Sender: doer.APIFormat(), |
|
|
|
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 { |
|
|
|
if err != nil { |
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
|
|
|
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -774,6 +832,7 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) { |
|
|
|
return fmt.Errorf("UpdateIssueCols: %v", err) |
|
|
|
return fmt.Errorf("UpdateIssueCols: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo) |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{ |
|
|
@ -785,7 +844,20 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
PullRequest: issue.PullRequest.APIFormat(), |
|
|
|
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(), |
|
|
|
Sender: doer.APIFormat(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -980,6 +1052,19 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, assigneeIDs []in |
|
|
|
log.Error(4, "MailParticipants: %v", err) |
|
|
|
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 |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|