summaryrefslogtreecommitdiffstats
path: root/modules/notification
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 02:27:50 +0100
committerGitHub <noreply@github.com>2021-12-10 02:27:50 +0100
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /modules/notification
parent[skip ci] Updated translations via Crowdin (diff)
downloadforgejo-719bddcd76610a63dadc8555760072957a11cf30.tar.xz
forgejo-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'modules/notification')
-rw-r--r--modules/notification/action/action.go23
-rw-r--r--modules/notification/action/action_test.go3
-rw-r--r--modules/notification/base/notifier.go29
-rw-r--r--modules/notification/base/null.go29
-rw-r--r--modules/notification/indexer/indexer.go11
-rw-r--r--modules/notification/mail/mail.go5
-rw-r--r--modules/notification/notification.go29
-rw-r--r--modules/notification/ui/ui.go5
-rw-r--r--modules/notification/webhook/webhook.go23
9 files changed, 83 insertions, 74 deletions
diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go
index 81a011fbed..376c5d103b 100644
--- a/modules/notification/action/action.go
+++ b/modules/notification/action/action.go
@@ -10,6 +10,7 @@ import (
"strings"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
@@ -89,7 +90,7 @@ func (a *actionNotifier) NotifyIssueChangeStatus(doer *user_model.User, issue *m
}
// NotifyCreateIssueComment notifies comment on an issue to notifiers
-func (a *actionNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+func (a *actionNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User) {
act := &models.Action{
ActUserID: doer.ID,
@@ -150,7 +151,7 @@ func (a *actionNotifier) NotifyNewPullRequest(pull *models.PullRequest, mentions
}
}
-func (a *actionNotifier) NotifyRenameRepository(doer *user_model.User, repo *models.Repository, oldRepoName string) {
+func (a *actionNotifier) NotifyRenameRepository(doer *user_model.User, repo *repo_model.Repository, oldRepoName string) {
log.Trace("action.ChangeRepositoryName: %s/%s", doer.Name, repo.Name)
if err := models.NotifyWatchers(&models.Action{
@@ -166,7 +167,7 @@ func (a *actionNotifier) NotifyRenameRepository(doer *user_model.User, repo *mod
}
}
-func (a *actionNotifier) NotifyTransferRepository(doer *user_model.User, repo *models.Repository, oldOwnerName string) {
+func (a *actionNotifier) NotifyTransferRepository(doer *user_model.User, repo *repo_model.Repository, oldOwnerName string) {
if err := models.NotifyWatchers(&models.Action{
ActUserID: doer.ID,
ActUser: doer,
@@ -180,7 +181,7 @@ func (a *actionNotifier) NotifyTransferRepository(doer *user_model.User, repo *m
}
}
-func (a *actionNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func (a *actionNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
if err := models.NotifyWatchers(&models.Action{
ActUserID: doer.ID,
ActUser: doer,
@@ -193,7 +194,7 @@ func (a *actionNotifier) NotifyCreateRepository(doer *user_model.User, u *user_m
}
}
-func (a *actionNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *models.Repository) {
+func (a *actionNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *repo_model.Repository) {
if err := models.NotifyWatchers(&models.Action{
ActUserID: doer.ID,
ActUser: doer,
@@ -298,7 +299,7 @@ func (*actionNotifier) NotifyPullRevieweDismiss(doer *user_model.User, review *m
}
}
-func (a *actionNotifier) NotifyPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (a *actionNotifier) NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
data, err := json.Marshal(commits)
if err != nil {
log.Error("Marshal: %v", err)
@@ -331,7 +332,7 @@ func (a *actionNotifier) NotifyPushCommits(pusher *user_model.User, repo *models
}
}
-func (a *actionNotifier) NotifyCreateRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (a *actionNotifier) NotifyCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
opType := models.ActionCommitRepo
if refType == "tag" {
// has sent same action in `NotifyPushCommits`, so skip it.
@@ -350,7 +351,7 @@ func (a *actionNotifier) NotifyCreateRef(doer *user_model.User, repo *models.Rep
}
}
-func (a *actionNotifier) NotifyDeleteRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (a *actionNotifier) NotifyDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
opType := models.ActionDeleteBranch
if refType == "tag" {
// has sent same action in `NotifyPushCommits`, so skip it.
@@ -369,7 +370,7 @@ func (a *actionNotifier) NotifyDeleteRef(doer *user_model.User, repo *models.Rep
}
}
-func (a *actionNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (a *actionNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
data, err := json.Marshal(commits)
if err != nil {
log.Error("json.Marshal: %v", err)
@@ -390,7 +391,7 @@ func (a *actionNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *mo
}
}
-func (a *actionNotifier) NotifySyncCreateRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (a *actionNotifier) NotifySyncCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
if err := models.NotifyWatchers(&models.Action{
ActUserID: repo.OwnerID,
ActUser: repo.MustOwner(),
@@ -404,7 +405,7 @@ func (a *actionNotifier) NotifySyncCreateRef(doer *user_model.User, repo *models
}
}
-func (a *actionNotifier) NotifySyncDeleteRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (a *actionNotifier) NotifySyncDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
if err := models.NotifyWatchers(&models.Action{
ActUserID: repo.OwnerID,
ActUser: repo.MustOwner(),
diff --git a/modules/notification/action/action_test.go b/modules/notification/action/action_test.go
index 2218bd46cb..3664b82104 100644
--- a/modules/notification/action/action_test.go
+++ b/modules/notification/action/action_test.go
@@ -10,6 +10,7 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -24,7 +25,7 @@ func TestRenameRepoAction(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
- repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{OwnerID: user.ID}).(*models.Repository)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID}).(*repo_model.Repository)
repo.Owner = user
oldRepoName := repo.Name
diff --git a/modules/notification/base/notifier.go b/modules/notification/base/notifier.go
index 24f6375a69..937476475a 100644
--- a/modules/notification/base/notifier.go
+++ b/modules/notification/base/notifier.go
@@ -6,6 +6,7 @@ package base
import (
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/repository"
)
@@ -14,12 +15,12 @@ import (
type Notifier interface {
Run()
- NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository)
- NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository)
- NotifyDeleteRepository(doer *user_model.User, repo *models.Repository)
- NotifyForkRepository(doer *user_model.User, oldRepo, repo *models.Repository)
- NotifyRenameRepository(doer *user_model.User, repo *models.Repository, oldRepoName string)
- NotifyTransferRepository(doer *user_model.User, repo *models.Repository, oldOwnerName string)
+ NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository)
+ NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository)
+ NotifyDeleteRepository(doer *user_model.User, repo *repo_model.Repository)
+ NotifyForkRepository(doer *user_model.User, oldRepo, repo *repo_model.Repository)
+ NotifyRenameRepository(doer *user_model.User, repo *repo_model.Repository, oldRepoName string)
+ NotifyTransferRepository(doer *user_model.User, repo *repo_model.Repository, oldOwnerName string)
NotifyNewIssue(issue *models.Issue, mentions []*user_model.User)
NotifyIssueChangeStatus(*user_model.User, *models.Issue, *models.Comment, bool)
@@ -42,7 +43,7 @@ type Notifier interface {
NotifyPullRequestPushCommits(doer *user_model.User, pr *models.PullRequest, comment *models.Comment)
NotifyPullRevieweDismiss(doer *user_model.User, review *models.Review, comment *models.Comment)
- NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+ NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User)
NotifyUpdateComment(*user_model.User, *models.Comment, string)
NotifyDeleteComment(*user_model.User, *models.Comment)
@@ -51,13 +52,13 @@ type Notifier interface {
NotifyUpdateRelease(doer *user_model.User, rel *models.Release)
NotifyDeleteRelease(doer *user_model.User, rel *models.Release)
- NotifyPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits)
- NotifyCreateRef(doer *user_model.User, repo *models.Repository, refType, refFullName string)
- NotifyDeleteRef(doer *user_model.User, repo *models.Repository, refType, refFullName string)
+ NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits)
+ NotifyCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string)
+ NotifyDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string)
- NotifySyncPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits)
- NotifySyncCreateRef(doer *user_model.User, repo *models.Repository, refType, refFullName string)
- NotifySyncDeleteRef(doer *user_model.User, repo *models.Repository, refType, refFullName string)
+ NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits)
+ NotifySyncCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string)
+ NotifySyncDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string)
- NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *models.Repository)
+ NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository)
}
diff --git a/modules/notification/base/null.go b/modules/notification/base/null.go
index 8a977e122b..062edf400d 100644
--- a/modules/notification/base/null.go
+++ b/modules/notification/base/null.go
@@ -6,6 +6,7 @@ package base
import (
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/repository"
)
@@ -23,7 +24,7 @@ func (*NullNotifier) Run() {
}
// NotifyCreateIssueComment places a place holder function
-func (*NullNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+func (*NullNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User) {
}
@@ -121,53 +122,53 @@ func (*NullNotifier) NotifyIssueChangeLabels(doer *user_model.User, issue *model
}
// NotifyCreateRepository places a place holder function
-func (*NullNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func (*NullNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
}
// NotifyDeleteRepository places a place holder function
-func (*NullNotifier) NotifyDeleteRepository(doer *user_model.User, repo *models.Repository) {
+func (*NullNotifier) NotifyDeleteRepository(doer *user_model.User, repo *repo_model.Repository) {
}
// NotifyForkRepository places a place holder function
-func (*NullNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *models.Repository) {
+func (*NullNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *repo_model.Repository) {
}
// NotifyMigrateRepository places a place holder function
-func (*NullNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func (*NullNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
}
// NotifyPushCommits notifies commits pushed to notifiers
-func (*NullNotifier) NotifyPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (*NullNotifier) NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
}
// NotifyCreateRef notifies branch or tag creation to notifiers
-func (*NullNotifier) NotifyCreateRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (*NullNotifier) NotifyCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
}
// NotifyDeleteRef notifies branch or tag deletion to notifiers
-func (*NullNotifier) NotifyDeleteRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (*NullNotifier) NotifyDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
}
// NotifyRenameRepository places a place holder function
-func (*NullNotifier) NotifyRenameRepository(doer *user_model.User, repo *models.Repository, oldRepoName string) {
+func (*NullNotifier) NotifyRenameRepository(doer *user_model.User, repo *repo_model.Repository, oldRepoName string) {
}
// NotifyTransferRepository places a place holder function
-func (*NullNotifier) NotifyTransferRepository(doer *user_model.User, repo *models.Repository, oldOwnerName string) {
+func (*NullNotifier) NotifyTransferRepository(doer *user_model.User, repo *repo_model.Repository, oldOwnerName string) {
}
// NotifySyncPushCommits places a place holder function
-func (*NullNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (*NullNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
}
// NotifySyncCreateRef places a place holder function
-func (*NullNotifier) NotifySyncCreateRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (*NullNotifier) NotifySyncCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
}
// NotifySyncDeleteRef places a place holder function
-func (*NullNotifier) NotifySyncDeleteRef(doer *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (*NullNotifier) NotifySyncDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
}
// NotifyRepoPendingTransfer places a place holder function
-func (*NullNotifier) NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *models.Repository) {
+func (*NullNotifier) NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository) {
}
diff --git a/modules/notification/indexer/indexer.go b/modules/notification/indexer/indexer.go
index 03914db03b..92fe3c5019 100644
--- a/modules/notification/indexer/indexer.go
+++ b/modules/notification/indexer/indexer.go
@@ -6,6 +6,7 @@ package indexer
import (
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
code_indexer "code.gitea.io/gitea/modules/indexer/code"
@@ -30,7 +31,7 @@ func NewNotifier() base.Notifier {
return &indexerNotifier{}
}
-func (r *indexerNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+func (r *indexerNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User) {
if comment.Type == models.CommentTypeComment {
if issue.Comments == nil {
@@ -107,14 +108,14 @@ func (r *indexerNotifier) NotifyDeleteComment(doer *user_model.User, comment *mo
}
}
-func (r *indexerNotifier) NotifyDeleteRepository(doer *user_model.User, repo *models.Repository) {
+func (r *indexerNotifier) NotifyDeleteRepository(doer *user_model.User, repo *repo_model.Repository) {
issue_indexer.DeleteRepoIssueIndexer(repo)
if setting.Indexer.RepoIndexerEnabled {
code_indexer.UpdateRepoIndexer(repo)
}
}
-func (r *indexerNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func (r *indexerNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
issue_indexer.UpdateRepoIndexer(repo)
if setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty {
code_indexer.UpdateRepoIndexer(repo)
@@ -124,7 +125,7 @@ func (r *indexerNotifier) NotifyMigrateRepository(doer *user_model.User, u *user
}
}
-func (r *indexerNotifier) NotifyPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (r *indexerNotifier) NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
code_indexer.UpdateRepoIndexer(repo)
}
@@ -133,7 +134,7 @@ func (r *indexerNotifier) NotifyPushCommits(pusher *user_model.User, repo *model
}
}
-func (r *indexerNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (r *indexerNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
code_indexer.UpdateRepoIndexer(repo)
}
diff --git a/modules/notification/mail/mail.go b/modules/notification/mail/mail.go
index c1c9e96135..6ad0ca0d85 100644
--- a/modules/notification/mail/mail.go
+++ b/modules/notification/mail/mail.go
@@ -8,6 +8,7 @@ import (
"fmt"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
@@ -27,7 +28,7 @@ func NewNotifier() base.Notifier {
return &mailNotifier{}
}
-func (m *mailNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+func (m *mailNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User) {
var act models.ActionType
if comment.Type == models.CommentTypeClose {
@@ -184,7 +185,7 @@ func (m *mailNotifier) NotifyNewRelease(rel *models.Release) {
mailer.MailNewRelease(rel)
}
-func (m *mailNotifier) NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *models.Repository) {
+func (m *mailNotifier) NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository) {
if err := mailer.SendRepoTransferNotifyMail(doer, newOwner, repo); err != nil {
log.Error("NotifyRepoPendingTransfer: %v", err)
}
diff --git a/modules/notification/notification.go b/modules/notification/notification.go
index 9bea38faf6..d976dfea66 100644
--- a/modules/notification/notification.go
+++ b/modules/notification/notification.go
@@ -6,6 +6,7 @@ package notification
import (
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/notification/action"
"code.gitea.io/gitea/modules/notification/base"
@@ -39,7 +40,7 @@ func NewContext() {
}
// NotifyCreateIssueComment notifies issue comment related message to notifiers
-func NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+func NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User) {
for _, notifier := range notifiers {
notifier.NotifyCreateIssueComment(doer, repo, issue, comment, mentions)
@@ -209,91 +210,91 @@ func NotifyIssueChangeLabels(doer *user_model.User, issue *models.Issue,
}
// NotifyCreateRepository notifies create repository to notifiers
-func NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
for _, notifier := range notifiers {
notifier.NotifyCreateRepository(doer, u, repo)
}
}
// NotifyMigrateRepository notifies create repository to notifiers
-func NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
for _, notifier := range notifiers {
notifier.NotifyMigrateRepository(doer, u, repo)
}
}
// NotifyTransferRepository notifies create repository to notifiers
-func NotifyTransferRepository(doer *user_model.User, repo *models.Repository, newOwnerName string) {
+func NotifyTransferRepository(doer *user_model.User, repo *repo_model.Repository, newOwnerName string) {
for _, notifier := range notifiers {
notifier.NotifyTransferRepository(doer, repo, newOwnerName)
}
}
// NotifyDeleteRepository notifies delete repository to notifiers
-func NotifyDeleteRepository(doer *user_model.User, repo *models.Repository) {
+func NotifyDeleteRepository(doer *user_model.User, repo *repo_model.Repository) {
for _, notifier := range notifiers {
notifier.NotifyDeleteRepository(doer, repo)
}
}
// NotifyForkRepository notifies fork repository to notifiers
-func NotifyForkRepository(doer *user_model.User, oldRepo, repo *models.Repository) {
+func NotifyForkRepository(doer *user_model.User, oldRepo, repo *repo_model.Repository) {
for _, notifier := range notifiers {
notifier.NotifyForkRepository(doer, oldRepo, repo)
}
}
// NotifyRenameRepository notifies repository renamed
-func NotifyRenameRepository(doer *user_model.User, repo *models.Repository, oldName string) {
+func NotifyRenameRepository(doer *user_model.User, repo *repo_model.Repository, oldName string) {
for _, notifier := range notifiers {
notifier.NotifyRenameRepository(doer, repo, oldName)
}
}
// NotifyPushCommits notifies commits pushed to notifiers
-func NotifyPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
for _, notifier := range notifiers {
notifier.NotifyPushCommits(pusher, repo, opts, commits)
}
}
// NotifyCreateRef notifies branch or tag creation to notifiers
-func NotifyCreateRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func NotifyCreateRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
for _, notifier := range notifiers {
notifier.NotifyCreateRef(pusher, repo, refType, refFullName)
}
}
// NotifyDeleteRef notifies branch or tag deletion to notifiers
-func NotifyDeleteRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func NotifyDeleteRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
for _, notifier := range notifiers {
notifier.NotifyDeleteRef(pusher, repo, refType, refFullName)
}
}
// NotifySyncPushCommits notifies commits pushed to notifiers
-func NotifySyncPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
for _, notifier := range notifiers {
notifier.NotifySyncPushCommits(pusher, repo, opts, commits)
}
}
// NotifySyncCreateRef notifies branch or tag creation to notifiers
-func NotifySyncCreateRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func NotifySyncCreateRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
for _, notifier := range notifiers {
notifier.NotifySyncCreateRef(pusher, repo, refType, refFullName)
}
}
// NotifySyncDeleteRef notifies branch or tag deletion to notifiers
-func NotifySyncDeleteRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func NotifySyncDeleteRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
for _, notifier := range notifiers {
notifier.NotifySyncDeleteRef(pusher, repo, refType, refFullName)
}
}
// NotifyRepoPendingTransfer notifies creation of pending transfer to notifiers
-func NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *models.Repository) {
+func NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository) {
for _, notifier := range notifiers {
notifier.NotifyRepoPendingTransfer(doer, newOwner, repo)
}
diff --git a/modules/notification/ui/ui.go b/modules/notification/ui/ui.go
index 04967fc589..25f015d0e5 100644
--- a/modules/notification/ui/ui.go
+++ b/modules/notification/ui/ui.go
@@ -6,6 +6,7 @@ package ui
import (
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
@@ -51,7 +52,7 @@ func (ns *notificationService) Run() {
graceful.GetManager().RunWithShutdownFns(ns.issueQueue.Run)
}
-func (ns *notificationService) NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+func (ns *notificationService) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User) {
var opts = issueNotificationOpts{
IssueID: issue.ID,
@@ -233,7 +234,7 @@ func (ns *notificationService) NotifyPullReviewRequest(doer *user_model.User, is
}
}
-func (ns *notificationService) NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *models.Repository) {
+func (ns *notificationService) NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository) {
if err := models.CreateRepoTransferNotification(doer, newOwner, repo); err != nil {
log.Error("NotifyRepoPendingTransfer: %v", err)
}
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index 378e7fd202..7e96ed0501 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/perm"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook"
@@ -73,7 +74,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *user_model.User, issue *m
}
}
-func (m *webhookNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *models.Repository) {
+func (m *webhookNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *repo_model.Repository) {
oldMode, _ := models.AccessLevel(doer, oldRepo)
mode, _ := models.AccessLevel(doer, repo)
@@ -101,7 +102,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, r
}
}
-func (m *webhookNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func (m *webhookNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
// Add to hook queue for created repo after session commit.
if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoCreated,
@@ -113,7 +114,7 @@ func (m *webhookNotifier) NotifyCreateRepository(doer *user_model.User, u *user_
}
}
-func (m *webhookNotifier) NotifyDeleteRepository(doer *user_model.User, repo *models.Repository) {
+func (m *webhookNotifier) NotifyDeleteRepository(doer *user_model.User, repo *repo_model.Repository) {
u := repo.MustOwner()
if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
@@ -126,7 +127,7 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *user_model.User, repo *mo
}
}
-func (m *webhookNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *models.Repository) {
+func (m *webhookNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
// Add to hook queue for created repo after session commit.
if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoCreated,
@@ -402,7 +403,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *user_model.User, c *models.C
}
}
-func (m *webhookNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *models.Repository,
+func (m *webhookNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User) {
mode, _ := models.AccessLevel(doer, repo)
@@ -564,7 +565,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *user_model.User, issu
}
}
-func (m *webhookNotifier) NotifyPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (m *webhookNotifier) NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
apiPusher := convert.ToUser(pusher, nil)
apiCommits, apiHeadCommit, err := commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL())
if err != nil {
@@ -697,7 +698,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
}
}
-func (m *webhookNotifier) NotifyCreateRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (m *webhookNotifier) NotifyCreateRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
apiPusher := convert.ToUser(pusher, nil)
apiRepo := convert.ToRepo(repo, perm.AccessModeNone)
refName := git.RefEndName(refFullName)
@@ -748,7 +749,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *user_model.User, p
}
}
-func (m *webhookNotifier) NotifyDeleteRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (m *webhookNotifier) NotifyDeleteRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
apiPusher := convert.ToUser(pusher, nil)
apiRepo := convert.ToRepo(repo, perm.AccessModeNone)
refName := git.RefEndName(refFullName)
@@ -793,7 +794,7 @@ func (m *webhookNotifier) NotifyDeleteRelease(doer *user_model.User, rel *models
sendReleaseHook(doer, rel, api.HookReleaseDeleted)
}
-func (m *webhookNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+func (m *webhookNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
apiPusher := convert.ToUser(pusher, nil)
apiCommits, apiHeadCommit, err := commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL())
if err != nil {
@@ -816,10 +817,10 @@ func (m *webhookNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *m
}
}
-func (m *webhookNotifier) NotifySyncCreateRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (m *webhookNotifier) NotifySyncCreateRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
m.NotifyCreateRef(pusher, repo, refType, refFullName)
}
-func (m *webhookNotifier) NotifySyncDeleteRef(pusher *user_model.User, repo *models.Repository, refType, refFullName string) {
+func (m *webhookNotifier) NotifySyncDeleteRef(pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
m.NotifyDeleteRef(pusher, repo, refType, refFullName)
}