summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-19 23:20:55 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-19 23:20:55 -0400
commita922c3ff6a65d6d0550f36d866a301a6737ca8a2 (patch)
treea7af095002f13ca5e60965df7287f0d3f4e82b6b /models
parent8b0f421eb504075b7500575515282cd7da8b0878 (diff)
downloadgitea-a922c3ff6a65d6d0550f36d866a301a6737ca8a2.tar.gz
gitea-a922c3ff6a65d6d0550f36d866a301a6737ca8a2.zip
Watch backend
Diffstat (limited to 'models')
-rw-r--r--models/models.go3
-rw-r--r--models/repo.go19
2 files changed, 16 insertions, 6 deletions
diff --git a/models/models.go b/models/models.go
index d6a6200eb3..2e0bb759d4 100644
--- a/models/models.go
+++ b/models/models.go
@@ -88,7 +88,8 @@ func setEngine() {
func init() {
setEngine()
- if err := orm.Sync(new(User), new(PublicKey), new(Repository), new(Access), new(Action)); err != nil {
+ if err := orm.Sync(new(User), new(PublicKey), new(Repository), new(Access),
+ new(Action), new(Watch)); err != nil {
fmt.Printf("sync database struct error: %v\n", err)
os.Exit(2)
}
diff --git a/models/repo.go b/models/repo.go
index fce7d7f530..187862fe27 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -43,11 +43,20 @@ type Repository struct {
Updated time.Time `xorm:"updated"`
}
-type Star struct {
- Id int64
- RepoId int64
- UserId int64
- Created time.Time `xorm:"created"`
+// Watch is connection request for receiving repository notifycation.
+type Watch struct {
+ Id int64
+ RepoId int64 `xorm:"UNIQUE(watch)"`
+ UserId int64 `xorm:"UNIQUE(watch)"`
+}
+
+func WatchRepo(userId, repoId int64, watch bool) (err error) {
+ if watch {
+ _, err = orm.Insert(&Watch{RepoId: repoId, UserId: userId})
+ } else {
+ _, err = orm.Delete(&Watch{0, repoId, userId})
+ }
+ return err
}
var (