summaryrefslogtreecommitdiff
path: root/system/api
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-01-10 09:45:17 -0800
committerSteve Manuel <nilslice@gmail.com>2017-01-10 09:45:17 -0800
commit5e120ac4d5f6e8c53e5828df6640b20dc5862faa (patch)
treedd22241be556cc51eeb7aab2abdd60a1156034c4 /system/api
parentd5b31987a05df02cf4129e8603f2304b191e0834 (diff)
adding initial support for third-party addons and the basic framework for how they are registered by the system
Diffstat (limited to 'system/api')
-rw-r--r--system/api/external.go7
-rw-r--r--system/api/handlers.go2
2 files changed, 7 insertions, 2 deletions
diff --git a/system/api/external.go b/system/api/external.go
index 302b7c9..662fc07 100644
--- a/system/api/external.go
+++ b/system/api/external.go
@@ -1,6 +1,7 @@
package api
import (
+ "context"
"fmt"
"log"
"net/http"
@@ -136,13 +137,17 @@ func externalContentHandler(res http.ResponseWriter, req *http.Request) {
spec = "__pending"
}
- _, err = db.SetContent(t+spec+":-1", req.PostForm)
+ id, err := db.SetContent(t+spec+":-1", req.PostForm)
if err != nil {
log.Println("[External] error:", err)
res.WriteHeader(http.StatusInternalServerError)
return
}
+ // set the target in the context so user can get saved value from db in hook
+ ctx := context.WithValue(req.Context(), "target", fmt.Sprintf("%s:%d", t, id))
+ req = req.WithContext(ctx)
+
err = hook.AfterSave(req)
if err != nil {
log.Println("[External] error:", err)
diff --git a/system/api/handlers.go b/system/api/handlers.go
index 869640f..1bc4fbb 100644
--- a/system/api/handlers.go
+++ b/system/api/handlers.go
@@ -178,7 +178,7 @@ func hide(it interface{}, res http.ResponseWriter, req *http.Request) bool {
// check if should be hidden
if h, ok := it.(item.Hideable); ok {
err := h.Hide(req)
- if err != nil && err == item.ErrAllowHiddenItem {
+ if err == item.ErrAllowHiddenItem {
return false
}