mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-17 11:59:30 +00:00
API Endpoint for watching (#191)
This commit is contained in:
parent
25b5ffb6af
commit
8a4161c723
3 changed files with 147 additions and 0 deletions
|
@ -1241,3 +1241,18 @@ func GetStarredRepos(userID int64, private bool) ([]*Repository, error) {
|
|||
}
|
||||
return repos, nil
|
||||
}
|
||||
|
||||
// GetWatchedRepos returns the repos watched by a particular user
|
||||
func GetWatchedRepos(userID int64, private bool) ([]*Repository, error) {
|
||||
sess := x.Where("watch.user_id=?", userID).
|
||||
Join("LEFT", "watch", "`repository`.id=`watch`.repo_id")
|
||||
if !private {
|
||||
sess = sess.And("is_private=?", false)
|
||||
}
|
||||
repos := make([]*Repository, 0, 10)
|
||||
err := sess.Find(&repos)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return repos, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue