diff options
author | slene <vslene@gmail.com> | 2014-03-28 00:32:19 +0800 |
---|---|---|
committer | slene <vslene@gmail.com> | 2014-03-28 00:32:19 +0800 |
commit | bce8586bc66c6827bf2ea6e27440f01476c2d151 (patch) | |
tree | c76e8cba33b131e1c6a21a06a57cde51e375a581 /models/repo.go | |
parent | 346db02d89ae0337956607eec43a0cd3f184fda8 (diff) | |
parent | 743593f7910d35f46cc18f06de12e59afa36fb65 (diff) |
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/models/repo.go b/models/repo.go index e7464357..1f638fe1 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()) } } |