diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-11-08 17:01:53 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-11-08 17:01:53 -0800 |
commit | 7fc144bee449641fb7d135cd6fdf59c8f5869a80 (patch) | |
tree | ba5a51c110973a12dc392c60860908cebaedd4e8 /system/api/external.go | |
parent | dfa5e33f99f8727d36420981156c1ba8400b17b8 (diff) |
adding remaining methods to Item for Hookable implementation and adding hooks to external submissions
Diffstat (limited to 'system/api/external.go')
-rw-r--r-- | system/api/external.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/system/api/external.go b/system/api/external.go index c9fb2a7..7eade92 100644 --- a/system/api/external.go +++ b/system/api/external.go @@ -99,11 +99,32 @@ func externalPostHandler(res http.ResponseWriter, req *http.Request) { req.PostForm.Del(discardKey) } + hook, ok := post.(content.Hookable) + if !ok { + log.Println("[External] error: Type", t, "does not implement content.Hookable or embed content.Item.") + res.WriteHeader(http.StatusBadRequest) + return + } + + err = hook.BeforeSave(req) + if err != nil { + log.Println("[External] error:", err) + res.WriteHeader(http.StatusInternalServerError) + return + } + _, err = db.SetContent(t+"_pending:-1", req.PostForm) if err != nil { log.Println("[External] error:", err) res.WriteHeader(http.StatusInternalServerError) return } + + err = hook.AfterSave(req) + if err != nil { + log.Println("[External] error:", err) + res.WriteHeader(http.StatusInternalServerError) + return + } } } |