]> source.dussan.org Git - gitea.git/commitdiff
Move notifywatchers from models to notification (#8907)
authorLunny Xiao <xiaolunwen@gmail.com>
Mon, 11 Nov 2019 03:39:41 +0000 (11:39 +0800)
committerGitHub <noreply@github.com>
Mon, 11 Nov 2019 03:39:41 +0000 (11:39 +0800)
models/repo.go
modules/notification/action/action.go

index d79a8fdf6106edf9a1a6b102a29912e403f2350d..176182e67d112efd9762fd21fa08afe79f86b8fc 100644 (file)
@@ -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)
index 52471c1107909c0a528d4242af82635cb7ff2cc2..d481bd8c4dd34a6ecc05d3c645a884e5e5088d55 100644 (file)
@@ -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)
+       }
+}