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