Move channel permission check back to using cache (#5454)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
210b510c87
Коммит
96f01d8c6c
@@ -4,6 +4,8 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
l4g "github.com/alecthomas/log4go"
|
l4g "github.com/alecthomas/log4go"
|
||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
)
|
)
|
||||||
@@ -32,16 +34,20 @@ func SessionHasPermissionToChannel(session model.Session, channelId string, perm
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
channelMember, err := GetChannelMember(channelId, session.UserId)
|
cmc := Srv.Store.Channel().GetAllChannelMembersForUser(session.UserId, true)
|
||||||
if err == nil {
|
|
||||||
roles := channelMember.GetRoles()
|
var channelRoles []string
|
||||||
if CheckIfRolesGrantPermission(roles, permission.Id) {
|
if cmcresult := <-cmc; cmcresult.Err == nil {
|
||||||
return true
|
ids := cmcresult.Data.(map[string]string)
|
||||||
|
if roles, ok := ids[channelId]; ok {
|
||||||
|
channelRoles = strings.Fields(roles)
|
||||||
|
if CheckIfRolesGrantPermission(channelRoles, permission.Id) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var channel *model.Channel
|
channel, err := GetChannel(channelId)
|
||||||
channel, err = GetChannel(channelId)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return SessionHasPermissionToTeam(session, channel.TeamId, permission)
|
return SessionHasPermissionToTeam(session, channel.TeamId, permission)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user