diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-11-11 11:39:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-11 11:39:41 +0800 |
commit | 273a24f22676b73a648fd2a5467e385ec41e84e2 (patch) | |
tree | 96396536c6734ad1339412603cae2120bb4aa8e5 | |
parent | 0e281384b56ff74ad795680a63cb574a27c2fdc1 (diff) | |
download | gitea-273a24f22676b73a648fd2a5467e385ec41e84e2.tar.gz gitea-273a24f22676b73a648fd2a5467e385ec41e84e2.zip |
Move notifywatchers from models to notification (#8907)
-rw-r--r-- | models/repo.go | 10 | ||||
-rw-r--r-- | modules/notification/action/action.go | 26 |
2 files changed, 26 insertions, 10 deletions
diff --git a/models/repo.go b/models/repo.go index d79a8fdf61..176182e67d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1470,16 +1470,6 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err return fmt.Errorf("watchRepo: %v", err) } } - if err = notifyWatchers(e, &Action{ - ActUserID: doer.ID, - ActUser: doer, - OpType: ActionCreateRepo, - RepoID: repo.ID, - Repo: repo, - IsPrivate: repo.IsPrivate, - }); err != nil { - return fmt.Errorf("notify watchers '%d/%d': %v", doer.ID, repo.ID, err) - } if err = copyDefaultWebhooksToRepo(e, repo.ID); err != nil { return fmt.Errorf("copyDefaultWebhooksToRepo: %v", err) diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 52471c1107..d481bd8c4d 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -91,3 +91,29 @@ func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models. log.Trace("action.renameRepoAction: %s/%s", doer.Name, repo.Name) } } + +func (a *actionNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) { + if err := models.NotifyWatchers(&models.Action{ + ActUserID: doer.ID, + ActUser: doer, + OpType: models.ActionCreateRepo, + RepoID: repo.ID, + Repo: repo, + IsPrivate: repo.IsPrivate, + }); err != nil { + log.Error("notify watchers '%d/%d': %v", doer.ID, repo.ID, err) + } +} + +func (a *actionNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) { + if err := models.NotifyWatchers(&models.Action{ + ActUserID: doer.ID, + ActUser: doer, + OpType: models.ActionCreateRepo, + RepoID: repo.ID, + Repo: repo, + IsPrivate: repo.IsPrivate, + }); err != nil { + log.Error("notify watchers '%d/%d': %v", doer.ID, repo.ID, err) + } +} |