MM-45193 Use context for channel logging (#20575)

Этот коммит содержится в:
Tim Scheuermann
2022-07-14 12:01:29 +03:00
коммит произвёл GitHub
родитель 5f4da3f308
Коммит 6dc897b04f
122 изменённых файлов: 2133 добавлений и 2082 удалений

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

@@ -739,7 +739,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
if inChannelId != "" {
if !*c.App.Config().TeamSettings.ExperimentalViewArchivedChannels {
channel, appErr := c.App.GetChannel(inChannelId)
channel, appErr := c.App.GetChannel(c.AppContext, inChannelId)
if appErr != nil {
c.Err = appErr
return
@@ -760,7 +760,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
profiles, err = c.App.GetUsersWithoutTeamPage(userGetOptions, c.IsSystemAdmin())
} else if notInChannelId != "" {
if !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), notInChannelId, model.PermissionReadChannel) {
if !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), notInChannelId, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
@@ -796,7 +796,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
profiles, err = c.App.GetUsersInTeamPage(userGetOptions, c.IsSystemAdmin())
}
} else if inChannelId != "" {
if !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), inChannelId, model.PermissionReadChannel) {
if !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), inChannelId, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
@@ -1002,12 +1002,12 @@ func searchUsers(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
if props.InChannelId != "" && !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), props.InChannelId, model.PermissionReadChannel) {
if props.InChannelId != "" && !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), props.InChannelId, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
if props.NotInChannelId != "" && !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), props.NotInChannelId, model.PermissionReadChannel) {
if props.NotInChannelId != "" && !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), props.NotInChannelId, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
@@ -1093,7 +1093,7 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
}
if channelId != "" {
if !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), channelId, model.PermissionReadChannel) {
if !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), channelId, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
@@ -2697,7 +2697,7 @@ func demoteUserToGuest(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if err := c.App.DemoteUserToGuest(user); err != nil {
if err := c.App.DemoteUserToGuest(c.AppContext, user); err != nil {
c.Err = err
return
}
@@ -2723,7 +2723,7 @@ func publishUserTyping(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if !c.App.HasPermissionToChannel(c.Params.UserId, typingRequest.ChannelId, model.PermissionCreatePost) {
if !c.App.HasPermissionToChannel(c.AppContext, c.Params.UserId, typingRequest.ChannelId, model.PermissionCreatePost) {
c.SetPermissionError(model.PermissionCreatePost)
return
}
@@ -2846,7 +2846,7 @@ func getChannelMembersForUser(c *Context, w http.ResponseWriter, r *http.Request
return
}
members, err := c.App.GetChannelMembersWithTeamDataForUserWithPagination(c.Params.UserId, c.Params.Page, c.Params.PerPage)
members, err := c.App.GetChannelMembersWithTeamDataForUserWithPagination(c.AppContext, c.Params.UserId, c.Params.Page, c.Params.PerPage)
if err != nil {
c.Err = err
return
@@ -3092,7 +3092,7 @@ func updateReadStateThreadByUser(c *Context, w http.ResponseWriter, r *http.Requ
return
}
thread, err := c.App.UpdateThreadReadForUser(c.AppContext.Session().Id, c.Params.UserId, c.Params.TeamId, c.Params.ThreadId, c.Params.Timestamp)
thread, err := c.App.UpdateThreadReadForUser(c.AppContext, c.AppContext.Session().Id, c.Params.UserId, c.Params.TeamId, c.Params.ThreadId, c.Params.Timestamp)
if err != nil {
c.Err = err
return
@@ -3128,7 +3128,7 @@ func setUnreadThreadByPostId(c *Context, w http.ResponseWriter, r *http.Request)
return
}
thread, err := c.App.UpdateThreadReadForUserByPost(c.AppContext.Session().Id, c.Params.UserId, c.Params.TeamId, c.Params.ThreadId, c.Params.PostId)
thread, err := c.App.UpdateThreadReadForUserByPost(c.AppContext, c.AppContext.Session().Id, c.Params.UserId, c.Params.TeamId, c.Params.ThreadId, c.Params.PostId)
if err != nil {
c.Err = err
return