diff options
author | Julien Levesy <jlevesy@gmail.com> | 2018-10-15 16:46:26 +0200 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2018-10-15 15:46:26 +0100 |
commit | 43bdbb0c3a0d93a8bf34ae5e2abbad4586a2581b (patch) | |
tree | aeca7af5d638e22c9e425f352494a1b17d72d83d /api4/brand.go | |
parent | 160d2785927d4729441dfa6ecd0d5536ec640687 (diff) | |
download | chat-43bdbb0c3a0d93a8bf34ae5e2abbad4586a2581b.tar.gz chat-43bdbb0c3a0d93a8bf34ae5e2abbad4586a2581b.tar.bz2 chat-43bdbb0c3a0d93a8bf34ae5e2abbad4586a2581b.zip |
Add a delete brand image action on the APIv4 (#9552)
Diffstat (limited to 'api4/brand.go')
-rw-r--r-- | api4/brand.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/api4/brand.go b/api4/brand.go index b6d353a29..54764860c 100644 --- a/api4/brand.go +++ b/api4/brand.go @@ -14,6 +14,7 @@ import ( func (api *API) InitBrand() { api.BaseRoutes.Brand.Handle("/image", api.ApiHandlerTrustRequester(getBrandImage)).Methods("GET") api.BaseRoutes.Brand.Handle("/image", api.ApiSessionRequired(uploadBrandImage)).Methods("POST") + api.BaseRoutes.Brand.Handle("/image", api.ApiSessionRequired(deleteBrandImage)).Methods("DELETE") } func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { @@ -71,3 +72,17 @@ func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusCreated) ReturnStatusOK(w) } + +func deleteBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { + if !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) { + c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) + return + } + + if err := c.App.DeleteBrandImage(); err != nil { + c.Err = err + return + } + + ReturnStatusOK(w) +} |