Merge branch 'master' into MM-45118_my_top_dms
Этот коммит содержится в:
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
)
|
||||
|
||||
func (api *API) InitImport() {
|
||||
@@ -26,11 +27,7 @@ func listImports(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
data, err := json.Marshal(imports)
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("listImports", "app.import.marshal.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
return
|
||||
if err := json.NewEncoder(w).Encode(imports); err != nil {
|
||||
c.Logger.Warn("Error writing imports", mlog.Err(err))
|
||||
}
|
||||
|
||||
w.Write(data)
|
||||
}
|
||||
|
||||
29
api4/post.go
29
api4/post.go
@@ -530,35 +530,6 @@ func getPostThread(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
rPost, err := c.App.GetSinglePost(c.Params.PostId, false)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
hasPermission := false
|
||||
becauseCompliance := false
|
||||
if c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), rPost.ChannelId, model.PermissionReadChannel) {
|
||||
hasPermission = true
|
||||
} else if channel, cErr := c.App.GetChannel(c.AppContext, rPost.ChannelId); cErr == nil {
|
||||
if channel.Type == model.ChannelTypeOpen &&
|
||||
c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), channel.TeamId, model.PermissionReadPublicChannel) {
|
||||
hasPermission = true
|
||||
if *c.App.Config().MessageExportSettings.EnableExport {
|
||||
hasPermission = false
|
||||
becauseCompliance = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !hasPermission {
|
||||
if becauseCompliance {
|
||||
c.Err = model.NewAppError("getPostThread", "api.post.compliance_enabled.join_channel_to_view_post", nil, "", http.StatusForbidden)
|
||||
} else {
|
||||
c.SetPermissionError(model.PermissionReadChannel)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// For now, by default we return all items unless it's set to maintain
|
||||
// backwards compatibility with mobile. But when the next ESR passes, we need to
|
||||
// change this to web.PerPageDefault.
|
||||
|
||||
@@ -928,7 +928,7 @@ func TestPatchPost(t *testing.T) {
|
||||
|
||||
t.Run("invalid requests", func(t *testing.T) {
|
||||
r, err := client.DoAPIPut("/posts/"+post.Id+"/patch", "garbage")
|
||||
require.EqualError(t, err, ": Invalid or missing post in request body.")
|
||||
require.EqualError(t, err, ": Invalid or missing post in request body., invalid character 'g' looking for beginning of value")
|
||||
require.Equal(t, http.StatusBadRequest, r.StatusCode, "wrong status code")
|
||||
|
||||
patch := &model.PostPatch{}
|
||||
@@ -2195,26 +2195,10 @@ func TestGetPostThread(t *testing.T) {
|
||||
|
||||
client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id)
|
||||
|
||||
messageExportEnabled := *th.App.Config().MessageExportSettings.EnableExport
|
||||
// Channel is public, and compliance export is OFF, should be able to read post
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.MessageExportSettings.EnableExport = false
|
||||
})
|
||||
// Channel is public, should be able to read post
|
||||
_, _, err = client.GetPostThread(th.BasicPost.Id, "", false)
|
||||
require.NoError(t, err)
|
||||
|
||||
// channel is public, and compliance export is ON, should NOT be able to read post
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.MessageExportSettings.EnableExport = true
|
||||
})
|
||||
_, resp, err = client.GetPostThread(th.BasicPost.Id, "", false)
|
||||
require.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.MessageExportSettings.EnableExport = messageExportEnabled
|
||||
})
|
||||
|
||||
privatePost := th.CreatePostWithClient(client, th.BasicPrivateChannel)
|
||||
|
||||
_, _, err = client.GetPostThread(privatePost.Id, "", false)
|
||||
|
||||
@@ -1028,6 +1028,7 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchUsers(t *testing.T) {
|
||||
t.Skip("MM-46450")
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1215,7 +1216,7 @@ func TestSearchUsers(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func findUserInList(id string, users []*model.User) bool {
|
||||
func findUserInList(id string, users []*model.User) bool { //nolint:unused
|
||||
for _, user := range users {
|
||||
if user.Id == id {
|
||||
return true
|
||||
|
||||
Ссылка в новой задаче
Block a user