|
|
@ -10,6 +10,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/notification/base" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
api "code.gitea.io/gitea/modules/structs" |
|
|
|
"code.gitea.io/gitea/modules/webhook" |
|
|
|
webhook_module "code.gitea.io/gitea/modules/webhook" |
|
|
|
) |
|
|
|
|
|
|
@ -251,6 +252,15 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode |
|
|
|
} |
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) { |
|
|
|
if err := issue.LoadRepo(); err != nil { |
|
|
|
log.Error("issue.LoadRepo: %v", err) |
|
|
|
return |
|
|
|
} |
|
|
|
if err := issue.LoadPoster(); err != nil { |
|
|
|
log.Error("issue.LoadPoster: %v", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo) |
|
|
|
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ |
|
|
|
Action: api.HookIssueOpened, |
|
|
@ -263,6 +273,32 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest) { |
|
|
|
if err := pull.LoadIssue(); err != nil { |
|
|
|
log.Error("pull.LoadIssue: %v", err) |
|
|
|
return |
|
|
|
} |
|
|
|
if err := pull.Issue.LoadRepo(); err != nil { |
|
|
|
log.Error("pull.Issue.LoadRepo: %v", err) |
|
|
|
return |
|
|
|
} |
|
|
|
if err := pull.Issue.LoadPoster(); err != nil { |
|
|
|
log.Error("pull.Issue.LoadPoster: %v", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
mode, _ := models.AccessLevel(pull.Issue.Poster, pull.Issue.Repo) |
|
|
|
if err := webhook.PrepareWebhooks(pull.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Index: pull.Issue.Index, |
|
|
|
PullRequest: pull.APIFormat(), |
|
|
|
Repository: pull.Issue.Repo.APIFormat(mode), |
|
|
|
Sender: pull.Issue.Poster.APIFormat(), |
|
|
|
}); err != nil { |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string) { |
|
|
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo) |
|
|
|
var err error |
|
|
|