Skip to content

Commit 273a24f

Browse files
authored
Move notifywatchers from models to notification (#8907)
1 parent 0e28138 commit 273a24f

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

models/repo.go

-10
Original file line numberDiff line numberDiff line change
@@ -1470,16 +1470,6 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
14701470
return fmt.Errorf("watchRepo: %v", err)
14711471
}
14721472
}
1473-
if err = notifyWatchers(e, &Action{
1474-
ActUserID: doer.ID,
1475-
ActUser: doer,
1476-
OpType: ActionCreateRepo,
1477-
RepoID: repo.ID,
1478-
Repo: repo,
1479-
IsPrivate: repo.IsPrivate,
1480-
}); err != nil {
1481-
return fmt.Errorf("notify watchers '%d/%d': %v", doer.ID, repo.ID, err)
1482-
}
14831473

14841474
if err = copyDefaultWebhooksToRepo(e, repo.ID); err != nil {
14851475
return fmt.Errorf("copyDefaultWebhooksToRepo: %v", err)

modules/notification/action/action.go

+26
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,29 @@ func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models.
9191
log.Trace("action.renameRepoAction: %s/%s", doer.Name, repo.Name)
9292
}
9393
}
94+
95+
func (a *actionNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
96+
if err := models.NotifyWatchers(&models.Action{
97+
ActUserID: doer.ID,
98+
ActUser: doer,
99+
OpType: models.ActionCreateRepo,
100+
RepoID: repo.ID,
101+
Repo: repo,
102+
IsPrivate: repo.IsPrivate,
103+
}); err != nil {
104+
log.Error("notify watchers '%d/%d': %v", doer.ID, repo.ID, err)
105+
}
106+
}
107+
108+
func (a *actionNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) {
109+
if err := models.NotifyWatchers(&models.Action{
110+
ActUserID: doer.ID,
111+
ActUser: doer,
112+
OpType: models.ActionCreateRepo,
113+
RepoID: repo.ID,
114+
Repo: repo,
115+
IsPrivate: repo.IsPrivate,
116+
}); err != nil {
117+
log.Error("notify watchers '%d/%d': %v", doer.ID, repo.ID, err)
118+
}
119+
}

0 commit comments

Comments
 (0)