1
0
Fork 0
forked from forgejo/forgejo

Watch backend

This commit is contained in:
Unknown 2014-03-19 23:20:55 -04:00
parent 8b0f421eb5
commit a922c3ff6a
7 changed files with 44 additions and 13 deletions

View file

@ -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,
})
}