diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-03-21 09:06:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-21 09:06:08 -0400 |
commit | fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b (patch) | |
tree | 708faaa67a39648dcd9deab953d836771f531d8f /api4/system.go | |
parent | 4968ef0759087f34c1674a385707f6befef810b7 (diff) | |
download | chat-fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b.tar.gz chat-fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b.tar.bz2 chat-fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b.zip |
Implement GET /audits endpoint for APIv4 (#5779)
* Implement GET /audits endpoint for APIv4
* Fix log unit test
Diffstat (limited to 'api4/system.go')
-rw-r--r-- | api4/system.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/api4/system.go b/api4/system.go index 5058b0e2f..972d526da 100644 --- a/api4/system.go +++ b/api4/system.go @@ -19,6 +19,7 @@ func InitSystem() { BaseRoutes.ApiRoot.Handle("/config", ApiSessionRequired(getConfig)).Methods("GET") BaseRoutes.ApiRoot.Handle("/config/reload", ApiSessionRequired(configReload)).Methods("POST") BaseRoutes.ApiRoot.Handle("/config", ApiSessionRequired(updateConfig)).Methods("PUT") + BaseRoutes.ApiRoot.Handle("/audits", ApiSessionRequired(getAudits)).Methods("GET") BaseRoutes.ApiRoot.Handle("/email/test", ApiSessionRequired(testEmail)).Methods("POST") BaseRoutes.ApiRoot.Handle("/database/recycle", ApiSessionRequired(databaseRecycle)).Methods("POST") BaseRoutes.ApiRoot.Handle("/caches/invalidate", ApiSessionRequired(invalidateCaches)).Methods("POST") @@ -96,6 +97,22 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) { w.Write([]byte(cfg.ToJson())) } +func getAudits(c *Context, w http.ResponseWriter, r *http.Request) { + if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) { + c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) + return + } + + audits, err := app.GetAuditsPage("", c.Params.Page, c.Params.PerPage) + + if err != nil { + c.Err = err + return + } + + w.Write([]byte(audits.ToJson())) +} + func databaseRecycle(c *Context, w http.ResponseWriter, r *http.Request) { if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) { |