MM-45272: Fix getPostThread permissions (#20565)

Summary
Fix permissions for the the getPostThread API Method.
User can view thread if user is member of the channel
User can view threads in public channels (in the user's team) that they're not a member of, only if compliance export is disabled.

Ticket Link
https://mattermost.atlassian.net/browse/MM-45272
Этот коммит содержится в:
Ashish Bhate
2022-07-28 20:25:20 +05:30
коммит произвёл GitHub
родитель 0ee05ce054
Коммит 04cd6d35e9
3 изменённых файлов: 50 добавлений и 1 удалений

Просмотреть файл

@@ -2191,10 +2191,26 @@ func TestGetPostThread(t *testing.T) {
client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id)
// Channel is public, should be able to read post
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
})
_, _, 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)