diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-24 17:49:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 17:49:20 +0800 |
commit | a666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch) | |
tree | 9ab1434b759a8a2cb275a83149903a823851e309 /modules/notification/webhook | |
parent | 4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff) | |
download | gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.tar.gz gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.zip |
Move user related model into models/user (#17781)
* Move user related model into models/user
* Fix lint for windows
* Fix windows lint
* Fix windows lint
* Move some tests in models
* Merge
Diffstat (limited to 'modules/notification/webhook')
-rw-r--r-- | modules/notification/webhook/webhook.go | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go index d5a947d9ac..8fe456e1c9 100644 --- a/modules/notification/webhook/webhook.go +++ b/modules/notification/webhook/webhook.go @@ -7,6 +7,7 @@ package webhook import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unit" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/models/webhook" "code.gitea.io/gitea/modules/convert" "code.gitea.io/gitea/modules/git" @@ -31,7 +32,7 @@ func NewNotifier() base.Notifier { return &webhookNotifier{} } -func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *models.Issue) { +func (m *webhookNotifier) NotifyIssueClearLabels(doer *user_model.User, issue *models.Issue) { if err := issue.LoadPoster(); err != nil { log.Error("loadPoster: %v", err) return @@ -71,7 +72,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model } } -func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) { +func (m *webhookNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *models.Repository) { oldMode, _ := models.AccessLevel(doer, oldRepo) mode, _ := models.AccessLevel(doer, repo) @@ -99,7 +100,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 *user_model.User, u *user_model.User, repo *models.Repository) { // Add to hook queue for created repo after session commit. if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{ Action: api.HookRepoCreated, @@ -111,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 *user_model.User, repo *models.Repository) { u := repo.MustOwner() if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{ @@ -124,7 +125,7 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models } } -func (m *webhookNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) { +func (m *webhookNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) { // Add to hook queue for created repo after session commit. if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{ Action: api.HookRepoCreated, @@ -136,7 +137,7 @@ func (m *webhookNotifier) NotifyMigrateRepository(doer *models.User, u *models.U } } -func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment) { +func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *user_model.User, issue *models.Issue, assignee *user_model.User, removed bool, comment *models.Comment) { if issue.IsPull { mode, _ := models.AccessLevelUnit(doer, issue.Repo, unit.TypePullRequests) @@ -182,7 +183,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo } } -func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) { +func (m *webhookNotifier) NotifyIssueChangeTitle(doer *user_model.User, issue *models.Issue, oldTitle string) { mode, _ := models.AccessLevel(issue.Poster, issue.Repo) var err error if issue.IsPull { @@ -223,7 +224,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model } } -func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) { +func (m *webhookNotifier) NotifyIssueChangeStatus(doer *user_model.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) { mode, _ := models.AccessLevel(issue.Poster, issue.Repo) var err error if issue.IsPull { @@ -263,7 +264,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode } } -func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue, mentions []*models.User) { +func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue, mentions []*user_model.User) { if err := issue.LoadRepo(); err != nil { log.Error("issue.LoadRepo: %v", err) return @@ -285,7 +286,7 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue, mentions []*models } } -func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest, mentions []*models.User) { +func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest, mentions []*user_model.User) { if err := pull.LoadIssue(); err != nil { log.Error("pull.LoadIssue: %v", err) return @@ -311,7 +312,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest, mention } } -func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string) { +func (m *webhookNotifier) NotifyIssueChangeContent(doer *user_model.User, issue *models.Issue, oldContent string) { mode, _ := models.AccessLevel(issue.Poster, issue.Repo) var err error if issue.IsPull { @@ -347,7 +348,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod } } -func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comment, oldContent string) { +func (m *webhookNotifier) NotifyUpdateComment(doer *user_model.User, c *models.Comment, oldContent string) { var err error if err = c.LoadPoster(); err != nil { @@ -400,8 +401,8 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme } } -func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository, - issue *models.Issue, comment *models.Comment, mentions []*models.User) { +func (m *webhookNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository, + issue *models.Issue, comment *models.Comment, mentions []*user_model.User) { mode, _ := models.AccessLevel(doer, repo) var err error @@ -430,7 +431,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode } } -func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models.Comment) { +func (m *webhookNotifier) NotifyDeleteComment(doer *user_model.User, comment *models.Comment) { var err error if err = comment.LoadPoster(); err != nil { @@ -475,7 +476,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models } -func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue, +func (m *webhookNotifier) NotifyIssueChangeLabels(doer *user_model.User, issue *models.Issue, addedLabels []*models.Label, removedLabels []*models.Label) { var err error @@ -520,7 +521,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode } } -func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue, oldMilestoneID int64) { +func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *user_model.User, issue *models.Issue, oldMilestoneID int64) { var hookAction api.HookIssueAction var err error if issue.MilestoneID > 0 { @@ -562,7 +563,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m } } -func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { +func (m *webhookNotifier) NotifyPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { apiPusher := convert.ToUser(pusher, nil) apiCommits, apiHeadCommit, err := commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL()) if err != nil { @@ -585,7 +586,7 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Re } } -func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) { +func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *user_model.User) { // Reload pull request information. if err := pr.LoadAttributes(); err != nil { log.Error("LoadAttributes: %v", err) @@ -623,7 +624,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mod } } -func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User, pr *models.PullRequest, oldBranch string) { +func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *user_model.User, pr *models.PullRequest, oldBranch string) { issue := pr.Issue if !issue.IsPull { return @@ -654,7 +655,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User, } } -func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review *models.Review, comment *models.Comment, mentions []*models.User) { +func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review *models.Review, comment *models.Comment, mentions []*user_model.User) { var reviewHookType webhook.HookEventType switch review.Type { @@ -695,7 +696,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review } } -func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repository, refType, refFullName string) { +func (m *webhookNotifier) NotifyCreateRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) { apiPusher := convert.ToUser(pusher, nil) apiRepo := convert.ToRepo(repo, models.AccessModeNone) refName := git.RefEndName(refFullName) @@ -725,7 +726,7 @@ func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repo } } -func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *models.PullRequest) { +func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *user_model.User, pr *models.PullRequest) { if err := pr.LoadIssue(); err != nil { log.Error("pr.LoadIssue: %v", err) return @@ -746,7 +747,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m } } -func (m *webhookNotifier) NotifyDeleteRef(pusher *models.User, repo *models.Repository, refType, refFullName string) { +func (m *webhookNotifier) NotifyDeleteRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) { apiPusher := convert.ToUser(pusher, nil) apiRepo := convert.ToRepo(repo, models.AccessModeNone) refName := git.RefEndName(refFullName) @@ -762,7 +763,7 @@ func (m *webhookNotifier) NotifyDeleteRef(pusher *models.User, repo *models.Repo } } -func sendReleaseHook(doer *models.User, rel *models.Release, action api.HookReleaseAction) { +func sendReleaseHook(doer *user_model.User, rel *models.Release, action api.HookReleaseAction) { if err := rel.LoadAttributes(); err != nil { log.Error("LoadAttributes: %v", err) return @@ -783,15 +784,15 @@ func (m *webhookNotifier) NotifyNewRelease(rel *models.Release) { sendReleaseHook(rel.Publisher, rel, api.HookReleasePublished) } -func (m *webhookNotifier) NotifyUpdateRelease(doer *models.User, rel *models.Release) { +func (m *webhookNotifier) NotifyUpdateRelease(doer *user_model.User, rel *models.Release) { sendReleaseHook(doer, rel, api.HookReleaseUpdated) } -func (m *webhookNotifier) NotifyDeleteRelease(doer *models.User, rel *models.Release) { +func (m *webhookNotifier) NotifyDeleteRelease(doer *user_model.User, rel *models.Release) { sendReleaseHook(doer, rel, api.HookReleaseDeleted) } -func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { +func (m *webhookNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { apiPusher := convert.ToUser(pusher, nil) apiCommits, apiHeadCommit, err := commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL()) if err != nil { @@ -814,10 +815,10 @@ func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *model } } -func (m *webhookNotifier) NotifySyncCreateRef(pusher *models.User, repo *models.Repository, refType, refFullName string) { +func (m *webhookNotifier) NotifySyncCreateRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) { m.NotifyCreateRef(pusher, repo, refType, refFullName) } -func (m *webhookNotifier) NotifySyncDeleteRef(pusher *models.User, repo *models.Repository, refType, refFullName string) { +func (m *webhookNotifier) NotifySyncDeleteRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) { m.NotifyDeleteRef(pusher, repo, refType, refFullName) } |