summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-10-05 09:54:55 -0400
committerUnknwon <u@gogs.io>2015-10-05 09:54:55 -0400
commitea6c6bc20aa8d159fa74ae95860c5a1df75a7147 (patch)
treea6796559cefd0999f59038ec42076135b709592b
parentdb00aa7653937ce62d1ffa37661e50ea4bee80cd (diff)
downloadgitea-ea6c6bc20aa8d159fa74ae95860c5a1df75a7147.tar.gz
gitea-ea6c6bc20aa8d159fa74ae95860c5a1df75a7147.zip
work on 1714
-rw-r--r--models/repo.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index 31e3660ae7..7cfc9c824b 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1601,15 +1601,19 @@ type Watch struct {
RepoID int64 `xorm:"UNIQUE(watch)"`
}
+func isWatching(e Engine, uid, repoId int64) bool {
+ has, _ := e.Get(&Watch{0, uid, repoId})
+ return has
+}
+
// IsWatching checks if user has watched given repository.
func IsWatching(uid, repoId int64) bool {
- has, _ := x.Get(&Watch{0, uid, repoId})
- return has
+ return isWatching(x, uid, repoId)
}
func watchRepo(e Engine, uid, repoId int64, watch bool) (err error) {
if watch {
- if IsWatching(uid, repoId) {
+ if isWatching(e, uid, repoId) {
return nil
}
if _, err = e.Insert(&Watch{RepoID: repoId, UserID: uid}); err != nil {
@@ -1617,7 +1621,7 @@ func watchRepo(e Engine, uid, repoId int64, watch bool) (err error) {
}
_, err = e.Exec("UPDATE `repository` SET num_watches = num_watches + 1 WHERE id = ?", repoId)
} else {
- if !IsWatching(uid, repoId) {
+ if !isWatching(e, uid, repoId) {
return nil
}
if _, err = e.Delete(&Watch{0, uid, repoId}); err != nil {