|
|
@ -13,7 +13,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/repository" |
|
|
|
"code.gitea.io/gitea/modules/repository" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
api "code.gitea.io/gitea/modules/structs" |
|
|
|
api "code.gitea.io/gitea/modules/structs" |
|
|
|
webhook_module "code.gitea.io/gitea/modules/webhook" |
|
|
|
webhook_services "code.gitea.io/gitea/services/webhook" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type webhookNotifier struct { |
|
|
|
type webhookNotifier struct { |
|
|
@ -48,7 +48,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(issue.PullRequest), |
|
|
|
PullRequest: convert.ToAPIPullRequest(issue.PullRequest), |
|
|
@ -56,7 +56,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{ |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
@ -74,7 +74,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo |
|
|
|
mode, _ := models.AccessLevel(doer, repo) |
|
|
|
mode, _ := models.AccessLevel(doer, repo) |
|
|
|
|
|
|
|
|
|
|
|
// forked webhook
|
|
|
|
// forked webhook
|
|
|
|
if err := webhook_module.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{ |
|
|
|
Forkee: convert.ToRepo(oldRepo, oldMode), |
|
|
|
Forkee: convert.ToRepo(oldRepo, oldMode), |
|
|
|
Repo: convert.ToRepo(repo, mode), |
|
|
|
Repo: convert.ToRepo(repo, mode), |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
@ -86,7 +86,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo |
|
|
|
|
|
|
|
|
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
if u.IsOrganization() { |
|
|
|
if u.IsOrganization() { |
|
|
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Repository: convert.ToRepo(repo, models.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(repo, models.AccessModeOwner), |
|
|
|
Organization: convert.ToUser(u, false, false), |
|
|
|
Organization: convert.ToUser(u, false, false), |
|
|
@ -99,7 +99,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo |
|
|
|
|
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) { |
|
|
|
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) { |
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Repository: convert.ToRepo(repo, models.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(repo, models.AccessModeOwner), |
|
|
|
Organization: convert.ToUser(u, false, false), |
|
|
|
Organization: convert.ToUser(u, false, false), |
|
|
@ -112,7 +112,7 @@ func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.Us |
|
|
|
func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) { |
|
|
|
func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) { |
|
|
|
u := repo.MustOwner() |
|
|
|
u := repo.MustOwner() |
|
|
|
|
|
|
|
|
|
|
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
Action: api.HookRepoDeleted, |
|
|
|
Action: api.HookRepoDeleted, |
|
|
|
Repository: convert.ToRepo(repo, models.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(repo, models.AccessModeOwner), |
|
|
|
Organization: convert.ToUser(u, false, false), |
|
|
|
Organization: convert.ToUser(u, false, false), |
|
|
@ -143,7 +143,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo |
|
|
|
apiPullRequest.Action = api.HookIssueAssigned |
|
|
|
apiPullRequest.Action = api.HookIssueAssigned |
|
|
|
} |
|
|
|
} |
|
|
|
// Assignee comment triggers a webhook
|
|
|
|
// Assignee comment triggers a webhook
|
|
|
|
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestAssign, apiPullRequest); err != nil { |
|
|
|
if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestAssign, apiPullRequest); err != nil { |
|
|
|
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err) |
|
|
|
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -161,7 +161,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo |
|
|
|
apiIssue.Action = api.HookIssueAssigned |
|
|
|
apiIssue.Action = api.HookIssueAssigned |
|
|
|
} |
|
|
|
} |
|
|
|
// Assignee comment triggers a webhook
|
|
|
|
// Assignee comment triggers a webhook
|
|
|
|
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueAssign, apiIssue); err != nil { |
|
|
|
if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueAssign, apiIssue); err != nil { |
|
|
|
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err) |
|
|
|
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -177,7 +177,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
@ -190,7 +190,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
@ -229,7 +229,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
apiPullRequest.Action = api.HookIssueReOpened |
|
|
|
apiPullRequest.Action = api.HookIssueReOpened |
|
|
|
} |
|
|
|
} |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest) |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
apiIssue := &api.IssuePayload{ |
|
|
|
apiIssue := &api.IssuePayload{ |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
@ -242,7 +242,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
apiIssue.Action = api.HookIssueReOpened |
|
|
|
apiIssue.Action = api.HookIssueReOpened |
|
|
|
} |
|
|
|
} |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue) |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue) |
|
|
|
} |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err) |
|
|
|
log.Error("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err) |
|
|
@ -260,7 +260,7 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo) |
|
|
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo) |
|
|
|
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
@ -286,7 +286,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := models.AccessLevel(pull.Issue.Poster, pull.Issue.Repo) |
|
|
|
mode, _ := models.AccessLevel(pull.Issue.Poster, pull.Issue.Repo) |
|
|
|
if err := webhook_module.PrepareWebhooks(pull.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(pull.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Index: pull.Issue.Index, |
|
|
|
Index: pull.Issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(pull), |
|
|
|
PullRequest: convert.ToAPIPullRequest(pull), |
|
|
@ -302,7 +302,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
@ -315,7 +315,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
@ -352,7 +352,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := models.AccessLevel(doer, c.Issue.Repo) |
|
|
|
mode, _ := models.AccessLevel(doer, c.Issue.Repo) |
|
|
|
if c.Issue.IsPull { |
|
|
|
if c.Issue.IsPull { |
|
|
|
err = webhook_module.PrepareWebhooks(c.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(c.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentEdited, |
|
|
|
Action: api.HookIssueCommentEdited, |
|
|
|
Issue: convert.ToAPIIssue(c.Issue), |
|
|
|
Issue: convert.ToAPIIssue(c.Issue), |
|
|
|
Comment: convert.ToComment(c), |
|
|
|
Comment: convert.ToComment(c), |
|
|
@ -366,7 +366,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme |
|
|
|
IsPull: true, |
|
|
|
IsPull: true, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(c.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(c.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentEdited, |
|
|
|
Action: api.HookIssueCommentEdited, |
|
|
|
Issue: convert.ToAPIIssue(c.Issue), |
|
|
|
Issue: convert.ToAPIIssue(c.Issue), |
|
|
|
Comment: convert.ToComment(c), |
|
|
|
Comment: convert.ToComment(c), |
|
|
@ -392,7 +392,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode |
|
|
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentCreated, |
|
|
|
Action: api.HookIssueCommentCreated, |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
@ -401,7 +401,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode |
|
|
|
IsPull: true, |
|
|
|
IsPull: true, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentCreated, |
|
|
|
Action: api.HookIssueCommentCreated, |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
@ -436,7 +436,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models |
|
|
|
mode, _ := models.AccessLevel(doer, comment.Issue.Repo) |
|
|
|
mode, _ := models.AccessLevel(doer, comment.Issue.Repo) |
|
|
|
|
|
|
|
|
|
|
|
if comment.Issue.IsPull { |
|
|
|
if comment.Issue.IsPull { |
|
|
|
err = webhook_module.PrepareWebhooks(comment.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(comment.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentDeleted, |
|
|
|
Action: api.HookIssueCommentDeleted, |
|
|
|
Issue: convert.ToAPIIssue(comment.Issue), |
|
|
|
Issue: convert.ToAPIIssue(comment.Issue), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
@ -445,7 +445,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models |
|
|
|
IsPull: true, |
|
|
|
IsPull: true, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(comment.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(comment.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentDeleted, |
|
|
|
Action: api.HookIssueCommentDeleted, |
|
|
|
Issue: convert.ToAPIIssue(comment.Issue), |
|
|
|
Issue: convert.ToAPIIssue(comment.Issue), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
|
Comment: convert.ToComment(comment), |
|
|
@ -485,7 +485,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode |
|
|
|
log.Error("LoadIssue: %v", err) |
|
|
|
log.Error("LoadIssue: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(issue.PullRequest), |
|
|
|
PullRequest: convert.ToAPIPullRequest(issue.PullRequest), |
|
|
@ -493,7 +493,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{ |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
@ -527,7 +527,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m |
|
|
|
log.Error("LoadIssue: %v", err) |
|
|
|
log.Error("LoadIssue: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestMilestone, &api.PullRequestPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestMilestone, &api.PullRequestPayload{ |
|
|
|
Action: hookAction, |
|
|
|
Action: hookAction, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(issue.PullRequest), |
|
|
|
PullRequest: convert.ToAPIPullRequest(issue.PullRequest), |
|
|
@ -535,7 +535,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
Sender: convert.ToUser(doer, false, false), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueMilestone, &api.IssuePayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueMilestone, &api.IssuePayload{ |
|
|
|
Action: hookAction, |
|
|
|
Action: hookAction, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
|
Issue: convert.ToAPIIssue(issue), |
|
|
@ -556,7 +556,7 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Re |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{ |
|
|
|
Ref: opts.RefFullName, |
|
|
|
Ref: opts.RefFullName, |
|
|
|
Before: opts.OldCommitID, |
|
|
|
Before: opts.OldCommitID, |
|
|
|
After: opts.NewCommitID, |
|
|
|
After: opts.NewCommitID, |
|
|
@ -602,7 +602,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mod |
|
|
|
Action: api.HookIssueClosed, |
|
|
|
Action: api.HookIssueClosed, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
err = webhook_module.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, apiPullRequest) |
|
|
|
err = webhook_services.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, apiPullRequest) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -621,7 +621,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User, |
|
|
|
} |
|
|
|
} |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
issue.PullRequest.Issue = issue |
|
|
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo) |
|
|
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo) |
|
|
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
|
Changes: &api.ChangesPayload{ |
|
|
@ -665,7 +665,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review |
|
|
|
log.Error("models.AccessLevel: %v", err) |
|
|
|
log.Error("models.AccessLevel: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if err := webhook_module.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueReviewed, |
|
|
|
Action: api.HookIssueReviewed, |
|
|
|
Index: review.Issue.Index, |
|
|
|
Index: review.Issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(pr), |
|
|
|
PullRequest: convert.ToAPIPullRequest(pr), |
|
|
@ -699,7 +699,7 @@ func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repo |
|
|
|
} |
|
|
|
} |
|
|
|
gitRepo.Close() |
|
|
|
gitRepo.Close() |
|
|
|
|
|
|
|
|
|
|
|
if err = webhook_module.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{ |
|
|
|
if err = webhook_services.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{ |
|
|
|
Ref: refName, |
|
|
|
Ref: refName, |
|
|
|
Sha: shaSum, |
|
|
|
Sha: shaSum, |
|
|
|
RefType: refType, |
|
|
|
RefType: refType, |
|
|
@ -720,7 +720,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := webhook_module.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequestSync, &api.PullRequestPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequestSync, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueSynchronized, |
|
|
|
Action: api.HookIssueSynchronized, |
|
|
|
Index: pr.Issue.Index, |
|
|
|
Index: pr.Issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(pr), |
|
|
|
PullRequest: convert.ToAPIPullRequest(pr), |
|
|
@ -736,7 +736,7 @@ func (m *webhookNotifier) NotifyDeleteRef(pusher *models.User, repo *models.Repo |
|
|
|
apiRepo := convert.ToRepo(repo, models.AccessModeNone) |
|
|
|
apiRepo := convert.ToRepo(repo, models.AccessModeNone) |
|
|
|
refName := git.RefEndName(refFullName) |
|
|
|
refName := git.RefEndName(refFullName) |
|
|
|
|
|
|
|
|
|
|
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{ |
|
|
|
Ref: refName, |
|
|
|
Ref: refName, |
|
|
|
RefType: refType, |
|
|
|
RefType: refType, |
|
|
|
PusherType: api.PusherTypeUser, |
|
|
|
PusherType: api.PusherTypeUser, |
|
|
@ -754,7 +754,7 @@ func sendReleaseHook(doer *models.User, rel *models.Release, action api.HookRele |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := models.AccessLevel(rel.Publisher, rel.Repo) |
|
|
|
mode, _ := models.AccessLevel(rel.Publisher, rel.Repo) |
|
|
|
if err := webhook_module.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{ |
|
|
|
Action: action, |
|
|
|
Action: action, |
|
|
|
Release: convert.ToRelease(rel), |
|
|
|
Release: convert.ToRelease(rel), |
|
|
|
Repository: convert.ToRepo(rel.Repo, mode), |
|
|
|
Repository: convert.ToRepo(rel.Repo, mode), |
|
|
@ -784,7 +784,7 @@ func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *model |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{ |
|
|
|
if err := webhook_services.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{ |
|
|
|
Ref: opts.RefFullName, |
|
|
|
Ref: opts.RefFullName, |
|
|
|
Before: opts.OldCommitID, |
|
|
|
Before: opts.OldCommitID, |
|
|
|
After: opts.NewCommitID, |
|
|
|
After: opts.NewCommitID, |
|
|
|