summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/watch.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/user/watch.go')
-rw-r--r--routers/api/v1/user/watch.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index 8bf4eeb505..230c819202 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -33,6 +33,15 @@ func getWatchedRepos(userID int64, private bool) ([]*api.Repository, error) {
// GetWatchedRepos returns the repos that the user specified in ctx is watching
func GetWatchedRepos(ctx *context.APIContext) {
+ // swagger:route GET /users/{username}/subscriptions userListSubscriptions
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: RepositoryList
+ // 500: error
+
user := GetUserByParams(ctx)
private := user.ID == ctx.User.ID
repos, err := getWatchedRepos(user.ID, private)
@@ -44,6 +53,15 @@ func GetWatchedRepos(ctx *context.APIContext) {
// GetMyWatchedRepos returns the repos that the authenticated user is watching
func GetMyWatchedRepos(ctx *context.APIContext) {
+ // swagger:route GET /user/subscriptions userCurrentListSubscriptions
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: RepositoryList
+ // 500: error
+
repos, err := getWatchedRepos(ctx.User.ID, true)
if err != nil {
ctx.Error(500, "getWatchedRepos", err)
@@ -54,6 +72,12 @@ func GetMyWatchedRepos(ctx *context.APIContext) {
// IsWatching returns whether the authenticated user is watching the repo
// specified in ctx
func IsWatching(ctx *context.APIContext) {
+ // swagger:route GET /repos/{username}/{reponame}/subscription userCurrentCheckSubscription
+ //
+ // Responses:
+ // 200: WatchInfo
+ // 404: notFound
+
if models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) {
ctx.JSON(200, api.WatchInfo{
Subscribed: true,
@@ -70,6 +94,12 @@ func IsWatching(ctx *context.APIContext) {
// Watch the repo specified in ctx, as the authenticated user
func Watch(ctx *context.APIContext) {
+ // swagger:route PUT /repos/{username}/{reponame}/subscription userCurrentPutSubscription
+ //
+ // Responses:
+ // 200: WatchInfo
+ // 500: error
+
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
if err != nil {
ctx.Error(500, "WatchRepo", err)
@@ -88,6 +118,12 @@ func Watch(ctx *context.APIContext) {
// Unwatch the repo specified in ctx, as the authenticated user
func Unwatch(ctx *context.APIContext) {
+ // swagger:route DELETE /repos/{username}/{reponame}/subscription userCurrentDeleteSubscription
+ //
+ // Responses:
+ // 204: empty
+ // 500: error
+
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
if err != nil {
ctx.Error(500, "UnwatchRepo", err)