app type transition (#7167)
Этот коммит содержится в:
@@ -29,12 +29,12 @@ func SessionHasPermissionToTeam(session model.Session, teamId string, permission
|
||||
return SessionHasPermissionTo(session, permission)
|
||||
}
|
||||
|
||||
func SessionHasPermissionToChannel(session model.Session, channelId string, permission *model.Permission) bool {
|
||||
func (a *App) SessionHasPermissionToChannel(session model.Session, channelId string, permission *model.Permission) bool {
|
||||
if channelId == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
cmc := Srv.Store.Channel().GetAllChannelMembersForUser(session.UserId, true)
|
||||
cmc := a.Srv.Store.Channel().GetAllChannelMembersForUser(session.UserId, true)
|
||||
|
||||
var channelRoles []string
|
||||
if cmcresult := <-cmc; cmcresult.Err == nil {
|
||||
@@ -47,7 +47,7 @@ func SessionHasPermissionToChannel(session model.Session, channelId string, perm
|
||||
}
|
||||
}
|
||||
|
||||
channel, err := GetChannel(channelId)
|
||||
channel, err := a.GetChannel(channelId)
|
||||
if err == nil && channel.TeamId != "" {
|
||||
return SessionHasPermissionToTeam(session, channel.TeamId, permission)
|
||||
}
|
||||
@@ -55,9 +55,9 @@ func SessionHasPermissionToChannel(session model.Session, channelId string, perm
|
||||
return SessionHasPermissionTo(session, permission)
|
||||
}
|
||||
|
||||
func SessionHasPermissionToChannelByPost(session model.Session, postId string, permission *model.Permission) bool {
|
||||
func (a *App) SessionHasPermissionToChannelByPost(session model.Session, postId string, permission *model.Permission) bool {
|
||||
var channelMember *model.ChannelMember
|
||||
if result := <-Srv.Store.Channel().GetMemberForPost(postId, session.UserId); result.Err == nil {
|
||||
if result := <-a.Srv.Store.Channel().GetMemberForPost(postId, session.UserId); result.Err == nil {
|
||||
channelMember = result.Data.(*model.ChannelMember)
|
||||
|
||||
if CheckIfRolesGrantPermission(channelMember.GetRoles(), permission.Id) {
|
||||
@@ -65,7 +65,7 @@ func SessionHasPermissionToChannelByPost(session model.Session, postId string, p
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().GetForPost(postId); result.Err == nil {
|
||||
if result := <-a.Srv.Store.Channel().GetForPost(postId); result.Err == nil {
|
||||
channel := result.Data.(*model.Channel)
|
||||
return SessionHasPermissionToTeam(session, channel.TeamId, permission)
|
||||
}
|
||||
@@ -89,8 +89,8 @@ func SessionHasPermissionToUser(session model.Session, userId string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func SessionHasPermissionToPost(session model.Session, postId string, permission *model.Permission) bool {
|
||||
post, err := GetSinglePost(postId)
|
||||
func (a *App) SessionHasPermissionToPost(session model.Session, postId string, permission *model.Permission) bool {
|
||||
post, err := a.GetSinglePost(postId)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -99,11 +99,11 @@ func SessionHasPermissionToPost(session model.Session, postId string, permission
|
||||
return true
|
||||
}
|
||||
|
||||
return SessionHasPermissionToChannel(session, post.ChannelId, permission)
|
||||
return a.SessionHasPermissionToChannel(session, post.ChannelId, permission)
|
||||
}
|
||||
|
||||
func HasPermissionTo(askingUserId string, permission *model.Permission) bool {
|
||||
user, err := GetUser(askingUserId)
|
||||
func (a *App) HasPermissionTo(askingUserId string, permission *model.Permission) bool {
|
||||
user, err := a.GetUser(askingUserId)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -113,12 +113,12 @@ func HasPermissionTo(askingUserId string, permission *model.Permission) bool {
|
||||
return CheckIfRolesGrantPermission(roles, permission.Id)
|
||||
}
|
||||
|
||||
func HasPermissionToTeam(askingUserId string, teamId string, permission *model.Permission) bool {
|
||||
func (a *App) HasPermissionToTeam(askingUserId string, teamId string, permission *model.Permission) bool {
|
||||
if teamId == "" || askingUserId == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
teamMember, err := GetTeamMember(teamId, askingUserId)
|
||||
teamMember, err := a.GetTeamMember(teamId, askingUserId)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -129,15 +129,15 @@ func HasPermissionToTeam(askingUserId string, teamId string, permission *model.P
|
||||
return true
|
||||
}
|
||||
|
||||
return HasPermissionTo(askingUserId, permission)
|
||||
return a.HasPermissionTo(askingUserId, permission)
|
||||
}
|
||||
|
||||
func HasPermissionToChannel(askingUserId string, channelId string, permission *model.Permission) bool {
|
||||
func (a *App) HasPermissionToChannel(askingUserId string, channelId string, permission *model.Permission) bool {
|
||||
if channelId == "" || askingUserId == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
channelMember, err := GetChannelMember(channelId, askingUserId)
|
||||
channelMember, err := a.GetChannelMember(channelId, askingUserId)
|
||||
if err == nil {
|
||||
roles := channelMember.GetRoles()
|
||||
if CheckIfRolesGrantPermission(roles, permission.Id) {
|
||||
@@ -146,17 +146,17 @@ func HasPermissionToChannel(askingUserId string, channelId string, permission *m
|
||||
}
|
||||
|
||||
var channel *model.Channel
|
||||
channel, err = GetChannel(channelId)
|
||||
channel, err = a.GetChannel(channelId)
|
||||
if err == nil {
|
||||
return HasPermissionToTeam(askingUserId, channel.TeamId, permission)
|
||||
return a.HasPermissionToTeam(askingUserId, channel.TeamId, permission)
|
||||
}
|
||||
|
||||
return HasPermissionTo(askingUserId, permission)
|
||||
return a.HasPermissionTo(askingUserId, permission)
|
||||
}
|
||||
|
||||
func HasPermissionToChannelByPost(askingUserId string, postId string, permission *model.Permission) bool {
|
||||
func (a *App) HasPermissionToChannelByPost(askingUserId string, postId string, permission *model.Permission) bool {
|
||||
var channelMember *model.ChannelMember
|
||||
if result := <-Srv.Store.Channel().GetMemberForPost(postId, askingUserId); result.Err == nil {
|
||||
if result := <-a.Srv.Store.Channel().GetMemberForPost(postId, askingUserId); result.Err == nil {
|
||||
channelMember = result.Data.(*model.ChannelMember)
|
||||
|
||||
if CheckIfRolesGrantPermission(channelMember.GetRoles(), permission.Id) {
|
||||
@@ -164,20 +164,20 @@ func HasPermissionToChannelByPost(askingUserId string, postId string, permission
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().GetForPost(postId); result.Err == nil {
|
||||
if result := <-a.Srv.Store.Channel().GetForPost(postId); result.Err == nil {
|
||||
channel := result.Data.(*model.Channel)
|
||||
return HasPermissionToTeam(askingUserId, channel.TeamId, permission)
|
||||
return a.HasPermissionToTeam(askingUserId, channel.TeamId, permission)
|
||||
}
|
||||
|
||||
return HasPermissionTo(askingUserId, permission)
|
||||
return a.HasPermissionTo(askingUserId, permission)
|
||||
}
|
||||
|
||||
func HasPermissionToUser(askingUserId string, userId string) bool {
|
||||
func (a *App) HasPermissionToUser(askingUserId string, userId string) bool {
|
||||
if askingUserId == userId {
|
||||
return true
|
||||
}
|
||||
|
||||
if HasPermissionTo(askingUserId, model.PERMISSION_EDIT_OTHER_USERS) {
|
||||
if a.HasPermissionTo(askingUserId, model.PERMISSION_EDIT_OTHER_USERS) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user