github.com/mattermost/mattermost-server/v5@v5.39.3/api4/import.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package api4 5 6 import ( 7 "encoding/json" 8 "net/http" 9 10 "github.com/mattermost/mattermost-server/v5/model" 11 ) 12 13 func (api *API) InitImport() { 14 api.BaseRoutes.Imports.Handle("", api.ApiSessionRequired(listImports)).Methods("GET") 15 } 16 17 func listImports(c *Context, w http.ResponseWriter, r *http.Request) { 18 if !c.IsSystemAdmin() { 19 c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) 20 return 21 } 22 23 imports, appErr := c.App.ListImports() 24 if appErr != nil { 25 c.Err = appErr 26 return 27 } 28 29 data, err := json.Marshal(imports) 30 if err != nil { 31 c.Err = model.NewAppError("listImports", "app.import.marshal.app_error", nil, err.Error(), http.StatusInternalServerError) 32 return 33 } 34 35 w.Write(data) 36 }