From a922c3ff6a65d6d0550f36d866a301a6737ca8a2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 19 Mar 2014 23:20:55 -0400 Subject: Watch backend --- routers/repo/single.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'routers/repo') diff --git a/routers/repo/single.go b/routers/repo/single.go index 3d0447ed..141a6cda 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -208,3 +208,25 @@ func Pulls(ctx *middleware.Context) { ctx.Data["IsRepoToolbarPulls"] = true ctx.HTML(200, "repo/pulls", ctx.Data) } + +func Action(ctx *middleware.Context, params martini.Params) { + var err error + switch params["action"] { + case "watch": + err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, true) + case "unwatch": + err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, false) + } + + if err != nil { + log.Error("repo.Action(%s): %v", params["action"], err) + ctx.JSON(200, map[string]interface{}{ + "ok": false, + "err": err.Error(), + }) + return + } + ctx.JSON(200, map[string]interface{}{ + "ok": true, + }) +} -- cgit v1.2.3