MM-37417: Push notification authz fix. (#18009)
* MM-37417: Push notification authz fix. * MM-37417: Tests new app method.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
285de45988
Коммит
37b1e6d048
24
app/post.go
24
app/post.go
@@ -1568,3 +1568,27 @@ func isPostMention(user *model.User, post *model.Post, keywords map[string][]str
|
||||
func (a *App) GetThreadMembershipsForUser(userID, teamID string) ([]*model.ThreadMembership, error) {
|
||||
return a.Srv().Store.Thread().GetMembershipsForUser(userID, teamID)
|
||||
}
|
||||
|
||||
func (a *App) GetPostIfAuthorized(postID string, session *model.Session) (*model.Post, *model.AppError) {
|
||||
post, err := a.GetSinglePost(postID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
channel, err := a.GetChannel(post.ChannelId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !a.SessionHasPermissionToChannel(*session, channel.Id, model.PermissionReadChannel) {
|
||||
if channel.Type == model.ChannelTypeOpen {
|
||||
if !a.SessionHasPermissionToTeam(*session, channel.TeamId, model.PermissionReadPublicChannel) {
|
||||
return nil, a.MakePermissionError(session, []*model.Permission{model.PermissionReadPublicChannel})
|
||||
}
|
||||
} else {
|
||||
return nil, a.MakePermissionError(session, []*model.Permission{model.PermissionReadChannel})
|
||||
}
|
||||
}
|
||||
|
||||
return post, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user