summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-07-12 14:13:25 +0100
committerSaturnino Abril <saturnino.abril@gmail.com>2017-07-12 22:13:25 +0900
commit2bf64b54c236945727a2d93afb57b1665d1daa7a (patch)
treea7b0b3c1114faf5e398b6cb06fd9e61fb818f7b9 /api4
parente975b84a12b8e3f547f4d811155d076a5a4fdcf9 (diff)
downloadchat-2bf64b54c236945727a2d93afb57b1665d1daa7a.tar.gz
chat-2bf64b54c236945727a2d93afb57b1665d1daa7a.tar.bz2
chat-2bf64b54c236945727a2d93afb57b1665d1daa7a.zip
PLT-7025: Fix Slack Import API. (#6905)
Diffstat (limited to 'api4')
-rw-r--r--api4/team.go8
-rw-r--r--api4/team_test.go8
2 files changed, 11 insertions, 5 deletions
diff --git a/api4/team.go b/api4/team.go
index 1cbd89481..98a672d93 100644
--- a/api4/team.go
+++ b/api4/team.go
@@ -5,7 +5,7 @@ package api4
import (
"bytes"
- "io"
+ "encoding/base64"
"net/http"
"strconv"
@@ -657,12 +657,12 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
- w.Header().Set("Content-Disposition", "attachment; filename=MattermostImportLog.txt")
- w.Header().Set("Content-Type", "application/octet-stream")
+ data := map[string]string{}
+ data["results"] = base64.StdEncoding.EncodeToString([]byte(log.Bytes()))
if c.Err != nil {
w.WriteHeader(c.Err.StatusCode)
}
- io.Copy(w, bytes.NewReader(log.Bytes()))
+ w.Write([]byte(model.MapToJson(data)))
}
func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
diff --git a/api4/team_test.go b/api4/team_test.go
index b517f67fe..440b2feb2 100644
--- a/api4/team_test.go
+++ b/api4/team_test.go
@@ -15,6 +15,7 @@ import (
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
+ "encoding/base64"
)
func TestCreateTeam(t *testing.T) {
@@ -1345,7 +1346,12 @@ func TestImportTeam(t *testing.T) {
fileResp, resp := th.SystemAdminClient.ImportTeam(data, binary.Size(data), "slack", "Fake_Team_Import.zip", th.BasicTeam.Id)
CheckNoError(t, resp)
- fileReturned := fmt.Sprintf("%s", fileResp)
+ fileData, err := base64.StdEncoding.DecodeString(fileResp["results"])
+ if err != nil {
+ t.Fatal("failed to decode base64 results data")
+ }
+
+ fileReturned := fmt.Sprintf("%s", fileData)
if !strings.Contains(fileReturned, "darth.vader@stardeath.com") {
t.Log(fileReturned)
t.Fatal("failed to report the user was imported")