diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-25 14:04:57 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-25 14:04:57 -0400 |
commit | d3b8e9daa1a22501c03564f2739f9fa8198fbdf1 (patch) | |
tree | 2e56cf4863b883984f760256b1898dd52bd593fd /models/action.go | |
parent | c5ff58272bcec72520f59a94445cd78d3e2dbf34 (diff) | |
download | gitea-d3b8e9daa1a22501c03564f2739f9fa8198fbdf1.tar.gz gitea-d3b8e9daa1a22501c03564f2739f9fa8198fbdf1.zip |
Add notify watcher action
Diffstat (limited to 'models/action.go')
-rw-r--r-- | models/action.go | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/models/action.go b/models/action.go index dffc0e537e..edf1bf58f9 100644 --- a/models/action.go +++ b/models/action.go @@ -19,6 +19,7 @@ const ( OP_STAR_REPO OP_FOLLOW_REPO OP_COMMIT_REPO + OP_CREATE_ISSUE OP_PULL_REQUEST ) @@ -67,34 +68,10 @@ func CommitRepoAction(userId int64, userName string, return err } - // Add feeds for user self and all watchers. - watches, err := GetWatches(repoId) - if err != nil { - log.Error("action.CommitRepoAction(get watches): %d/%s", userId, repoName) + if err = NotifyWatchers(userId, repoId, OP_COMMIT_REPO, userName, repoName, refName, string(bs)); err != nil { + log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName) return err } - watches = append(watches, Watch{UserId: userId}) - - for i := range watches { - if userId == 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: OP_COMMIT_REPO, - Content: string(bs), - RepoId: repoId, - RepoName: repoName, - RefName: refName, - }) - if err != nil { - log.Error("action.CommitRepoAction(notify watches): %d/%s", userId, repoName) - return err - } - } // Update repository last update time. repo, err := GetRepositoryByName(userId, repoName) |