[MM-56174] Account for archived channels in channel member for post permission check (#25837)

* [MM-56174] Account for archived channels in channel member for post permission check

* Add tests
Этот коммит содержится в:
Devin Binnie
2024-01-10 15:50:00 -05:00
коммит произвёл GitHub
родитель 1d108f0d9f
Коммит 43cca04f04
9 изменённых файлов: 129 добавлений и 21 удалений

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

@@ -4917,11 +4917,11 @@ func testChannelStoreGetMemberForPost(t *testing.T, rctx request.CTX, ss store.S
})
require.NoError(t, nErr)
r1, err := ss.Channel().GetMemberForPost(p1.Id, m1.UserId)
r1, err := ss.Channel().GetMemberForPost(p1.Id, m1.UserId, false)
require.NoError(t, err, err)
require.Equal(t, channelMemberToJSON(t, m1), channelMemberToJSON(t, r1), "invalid returned channel member")
_, err = ss.Channel().GetMemberForPost(p1.Id, model.NewId())
_, err = ss.Channel().GetMemberForPost(p1.Id, model.NewId(), false)
require.Error(t, err, "shouldn't have returned a member")
}

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

@@ -1288,25 +1288,25 @@ func (_m *ChannelStore) GetMemberCountsByGroup(ctx context.Context, channelID st
return r0, r1
}
// GetMemberForPost provides a mock function with given fields: postID, userID
func (_m *ChannelStore) GetMemberForPost(postID string, userID string) (*model.ChannelMember, error) {
ret := _m.Called(postID, userID)
// GetMemberForPost provides a mock function with given fields: postID, userID, includeArchivedChannels
func (_m *ChannelStore) GetMemberForPost(postID string, userID string, includeArchivedChannels bool) (*model.ChannelMember, error) {
ret := _m.Called(postID, userID, includeArchivedChannels)
var r0 *model.ChannelMember
var r1 error
if rf, ok := ret.Get(0).(func(string, string) (*model.ChannelMember, error)); ok {
return rf(postID, userID)
if rf, ok := ret.Get(0).(func(string, string, bool) (*model.ChannelMember, error)); ok {
return rf(postID, userID, includeArchivedChannels)
}
if rf, ok := ret.Get(0).(func(string, string) *model.ChannelMember); ok {
r0 = rf(postID, userID)
if rf, ok := ret.Get(0).(func(string, string, bool) *model.ChannelMember); ok {
r0 = rf(postID, userID, includeArchivedChannels)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.ChannelMember)
}
}
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(postID, userID)
if rf, ok := ret.Get(1).(func(string, string, bool) error); ok {
r1 = rf(postID, userID, includeArchivedChannels)
} else {
r1 = ret.Error(1)
}