summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-27 11:37:33 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-27 11:37:33 -0400
commitf470c241d6b1de30e4f500a6cf69f6ecd0cf8b41 (patch)
treeaba8fc0973c410c938af5988e2e5d09374252738 /models/repo.go
parentc796ed3849e3cd5b28cc8234edc71bbedafbc7da (diff)
downloadgitea-f470c241d6b1de30e4f500a6cf69f6ecd0cf8b41.tar.gz
gitea-f470c241d6b1de30e4f500a6cf69f6ecd0cf8b41.zip
IP: RC Code Review
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go21
1 files changed, 6 insertions, 15 deletions
diff --git a/models/repo.go b/models/repo.go
index e74643577a..1f638fe14f 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -485,30 +485,21 @@ func GetWatches(repoId int64) ([]Watch, error) {
}
// NotifyWatchers creates batch of actions for every watcher.
-func NotifyWatchers(userId, repoId int64, opType int, userName, repoName, refName, content string) error {
+func NotifyWatchers(act *Action) error {
// Add feeds for user self and all watchers.
- watches, err := GetWatches(repoId)
+ watches, err := GetWatches(act.RepoId)
if err != nil {
return errors.New("repo.NotifyWatchers(get watches): " + err.Error())
}
- watches = append(watches, Watch{UserId: userId})
+ watches = append(watches, Watch{UserId: act.ActUserId})
for i := range watches {
- if userId == watches[i].UserId && i > 0 {
+ if act.ActUserId == watches[i].UserId && i > 0 {
continue // Do not add twice in case author watches his/her repository.
}
- _, err = orm.InsertOne(&Action{
- UserId: watches[i].UserId,
- ActUserId: userId,
- ActUserName: userName,
- OpType: opType,
- Content: content,
- RepoId: repoId,
- RepoName: repoName,
- RefName: refName,
- })
- if err != nil {
+ act.UserId = watches[i].UserId
+ if _, err = orm.InsertOne(act); err != nil {
return errors.New("repo.NotifyWatchers(create action): " + err.Error())
}
}