diff options
author | =Corey Hulen <corey@hulen.com> | 2015-09-10 15:15:04 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-09-10 15:15:04 -0700 |
commit | 83b04181da84d0456dfa02b8d52953eb3fd3d7d1 (patch) | |
tree | 49510d8a6d4be6aeed9a86816cffcbc82d66b09b /api/team.go | |
parent | 1108ac53063bedcfe00647fa0577e91cf60555de (diff) | |
parent | 927b474005b9e6c03f7385f4d1a06626dd0450e3 (diff) | |
download | chat-83b04181da84d0456dfa02b8d52953eb3fd3d7d1.tar.gz chat-83b04181da84d0456dfa02b8d52953eb3fd3d7d1.tar.bz2 chat-83b04181da84d0456dfa02b8d52953eb3fd3d7d1.zip |
merging
Diffstat (limited to 'api/team.go')
-rw-r--r-- | api/team.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/api/team.go b/api/team.go index 8c0be9486..9288b86cb 100644 --- a/api/team.go +++ b/api/team.go @@ -32,7 +32,9 @@ func InitTeam(r *mux.Router) { sr.Handle("/update_name", ApiUserRequired(updateTeamDisplayName)).Methods("POST") sr.Handle("/update_valet_feature", ApiUserRequired(updateValetFeature)).Methods("POST") sr.Handle("/me", ApiUserRequired(getMyTeam)).Methods("GET") + // These should be moved to the global admain console sr.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST") + sr.Handle("/export_team", ApiUserRequired(exportTeam)).Methods("GET") } func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) { @@ -683,3 +685,22 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/octet-stream") http.ServeContent(w, r, "MattermostImportLog.txt", time.Now(), bytes.NewReader(log.Bytes())) } + +func exportTeam(c *Context, w http.ResponseWriter, r *http.Request) { + if !c.HasPermissionsToTeam(c.Session.TeamId, "export") || !c.IsTeamAdmin(c.Session.UserId) { + c.Err = model.NewAppError("exportTeam", "Only a team admin can export data.", "userId="+c.Session.UserId) + c.Err.StatusCode = http.StatusForbidden + return + } + + options := ExportOptionsFromJson(r.Body) + + if link, err := ExportToFile(options); err != nil { + c.Err = err + return + } else { + result := map[string]string{} + result["link"] = link + w.Write([]byte(model.MapToJson(result))) + } +} |