mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Finish watch backend
This commit is contained in:
@@ -50,6 +50,7 @@ type Watch struct {
|
||||
UserId int64 `xorm:"UNIQUE(watch)"`
|
||||
}
|
||||
|
||||
// Watch or unwatch repository.
|
||||
func WatchRepo(userId, repoId int64, watch bool) (err error) {
|
||||
if watch {
|
||||
_, err = orm.Insert(&Watch{RepoId: repoId, UserId: userId})
|
||||
@@ -59,6 +60,13 @@ func WatchRepo(userId, repoId int64, watch bool) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// GetWatches returns all watches of given repository.
|
||||
func GetWatches(repoId int64) ([]Watch, error) {
|
||||
watches := make([]Watch, 0, 10)
|
||||
err := orm.Find(&watches, &Watch{RepoId: repoId})
|
||||
return watches, err
|
||||
}
|
||||
|
||||
var (
|
||||
gitInitLocker = sync.Mutex{}
|
||||
LanguageIgns, Licenses []string
|
||||
|
Reference in New Issue
Block a user