aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-19 23:20:55 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-19 23:20:55 -0400
commita922c3ff6a65d6d0550f36d866a301a6737ca8a2 (patch)
treea7af095002f13ca5e60965df7287f0d3f4e82b6b /routers
parent8b0f421eb504075b7500575515282cd7da8b0878 (diff)
Watch backend
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/single.go22
-rw-r--r--routers/user/setting.go2
2 files changed, 22 insertions, 2 deletions
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,
+ })
+}
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 719e0c19..053f327f 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -93,7 +93,6 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
if ctx.Req.Method == "DELETE" || ctx.Query("_method") == "DELETE" {
id, err := strconv.ParseInt(ctx.Query("id"), 10, 64)
if err != nil {
- ctx.Data["ErrorMsg"] = err
log.Error("ssh.DelPublicKey: %v", err)
ctx.JSON(200, map[string]interface{}{
"ok": false,
@@ -107,7 +106,6 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
}
if err = models.DeletePublicKey(k); err != nil {
- ctx.Data["ErrorMsg"] = err
log.Error("ssh.DelPublicKey: %v", err)
ctx.JSON(200, map[string]interface{}{
"ok": false,