[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1d108f0d9f
Коммит
43cca04f04
@@ -2107,7 +2107,7 @@ func (s SqlChannelStore) IsUserInChannelUseCache(userId string, channelId string
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetMemberForPost(postId string, userId string) (*model.ChannelMember, error) {
|
||||
func (s SqlChannelStore) GetMemberForPost(postId string, userId string, includeArchivedChannels bool) (*model.ChannelMember, error) {
|
||||
var dbMember channelMemberWithSchemeRoles
|
||||
query := `
|
||||
SELECT
|
||||
@@ -2147,6 +2147,10 @@ func (s SqlChannelStore) GetMemberForPost(postId string, userId string) (*model.
|
||||
ChannelMembers.UserId = ?
|
||||
AND
|
||||
Posts.Id = ?`
|
||||
|
||||
if !includeArchivedChannels {
|
||||
query += " AND Channels.DeleteAt = 0"
|
||||
}
|
||||
if err := s.GetReplicaX().Get(&dbMember, query, userId, postId); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get ChannelMember with postId=%s and userId=%s", postId, userId)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user