Migrate store methods to use request.Context instead of context.Context (#24836)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0d5a8b8841
Коммит
13c05a571f
@@ -182,7 +182,7 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext.Session().UserId, c.Params.UserId)
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext, c.AppContext.Session().UserId, c.Params.UserId)
|
||||
if err != nil {
|
||||
c.SetPermissionError(model.PermissionViewMembers)
|
||||
return
|
||||
@@ -238,7 +238,7 @@ func getUserByUsername(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
user, err := c.App.GetUserByUsername(c.Params.Username)
|
||||
if err != nil {
|
||||
restrictions, err2 := c.App.GetViewUsersRestrictions(c.AppContext.Session().UserId)
|
||||
restrictions, err2 := c.App.GetViewUsersRestrictions(c.AppContext, c.AppContext.Session().UserId)
|
||||
if err2 != nil {
|
||||
c.Err = err2
|
||||
return
|
||||
@@ -251,7 +251,7 @@ func getUserByUsername(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext.Session().UserId, user.Id)
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext, c.AppContext.Session().UserId, user.Id)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -306,7 +306,7 @@ func getUserByEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
user, err := c.App.GetUserByEmail(c.Params.Email)
|
||||
if err != nil {
|
||||
restrictions, err2 := c.App.GetViewUsersRestrictions(c.AppContext.Session().UserId)
|
||||
restrictions, err2 := c.App.GetViewUsersRestrictions(c.AppContext, c.AppContext.Session().UserId)
|
||||
if err2 != nil {
|
||||
c.Err = err2
|
||||
return
|
||||
@@ -319,7 +319,7 @@ func getUserByEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext.Session().UserId, user.Id)
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext, c.AppContext.Session().UserId, user.Id)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -349,7 +349,7 @@ func getDefaultProfileImage(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext.Session().UserId, c.Params.UserId)
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext, c.AppContext.Session().UserId, c.Params.UserId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -383,7 +383,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext.Session().UserId, c.Params.UserId)
|
||||
canSee, err := c.App.UserCanSeeOtherUser(c.AppContext, c.AppContext.Session().UserId, c.Params.UserId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -538,7 +538,7 @@ func getTotalUsersStats(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
restrictions, err := c.App.GetViewUsersRestrictions(c.AppContext.Session().UserId)
|
||||
restrictions, err := c.App.GetViewUsersRestrictions(c.AppContext, c.AppContext.Session().UserId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -769,7 +769,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
restrictions, appErr := c.App.GetViewUsersRestrictions(c.AppContext.Session().UserId)
|
||||
restrictions, appErr := c.App.GetViewUsersRestrictions(c.AppContext, c.AppContext.Session().UserId)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
@@ -906,7 +906,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
userGetOptions, appErr = c.App.RestrictUsersGetByPermissions(c.AppContext.Session().UserId, userGetOptions)
|
||||
userGetOptions, appErr = c.App.RestrictUsersGetByPermissions(c.AppContext, c.AppContext.Session().UserId, userGetOptions)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
@@ -979,7 +979,7 @@ func getUsersByIds(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
options.Since = since
|
||||
}
|
||||
|
||||
restrictions, appErr := c.App.GetViewUsersRestrictions(c.AppContext.Session().UserId)
|
||||
restrictions, appErr := c.App.GetViewUsersRestrictions(c.AppContext, c.AppContext.Session().UserId)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
@@ -1009,7 +1009,7 @@ func getUsersByNames(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
restrictions, appErr := c.App.GetViewUsersRestrictions(c.AppContext.Session().UserId)
|
||||
restrictions, appErr := c.App.GetViewUsersRestrictions(c.AppContext, c.AppContext.Session().UserId)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
@@ -1124,7 +1124,7 @@ func searchUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
options.AllowFullNames = *c.App.Config().PrivacySettings.ShowFullName
|
||||
}
|
||||
|
||||
options, appErr := c.App.RestrictUsersSearchByPermissions(c.AppContext.Session().UserId, options)
|
||||
options, appErr := c.App.RestrictUsersSearchByPermissions(c.AppContext, c.AppContext.Session().UserId, options)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
@@ -1187,7 +1187,7 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
var autocomplete model.UserAutocomplete
|
||||
|
||||
var err *model.AppError
|
||||
options, err = c.App.RestrictUsersSearchByPermissions(c.AppContext.Session().UserId, options)
|
||||
options, err = c.App.RestrictUsersSearchByPermissions(c.AppContext, c.AppContext.Session().UserId, options)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -2081,7 +2081,7 @@ func Logout(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
c.RemoveSessionCookie(w, r)
|
||||
if c.AppContext.Session().Id != "" {
|
||||
if err := c.App.RevokeSessionById(c.AppContext.Session().Id); err != nil {
|
||||
if err := c.App.RevokeSessionById(c.AppContext, c.AppContext.Session().Id); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -2102,7 +2102,7 @@ func getSessions(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sessions, appErr := c.App.GetSessions(c.Params.UserId)
|
||||
sessions, appErr := c.App.GetSessions(c.AppContext, c.Params.UserId)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
@@ -2143,7 +2143,7 @@ func revokeSession(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
audit.AddEventParameter(auditRec, "session_id", sessionId)
|
||||
|
||||
session, err := c.App.GetSessionById(sessionId)
|
||||
session, err := c.App.GetSessionById(c.AppContext, sessionId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -2157,7 +2157,7 @@ func revokeSession(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.App.RevokeSession(session); err != nil {
|
||||
if err := c.App.RevokeSession(c.AppContext, session); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -2183,7 +2183,7 @@ func revokeAllSessionsForUser(c *Context, w http.ResponseWriter, r *http.Request
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.App.RevokeAllSessions(c.Params.UserId); err != nil {
|
||||
if err := c.App.RevokeAllSessions(c.AppContext, c.Params.UserId); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -2228,7 +2228,7 @@ func attachDeviceId(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
audit.AddEventParameter(auditRec, "device_id", deviceId)
|
||||
|
||||
// A special case where we logout of all other sessions with the same device id
|
||||
if err := c.App.RevokeSessionsForDeviceId(c.AppContext.Session().UserId, deviceId, c.AppContext.Session().Id); err != nil {
|
||||
if err := c.App.RevokeSessionsForDeviceId(c.AppContext, c.AppContext.Session().UserId, deviceId, c.AppContext.Session().Id); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -2388,7 +2388,7 @@ func switchAccountType(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
link, err = c.App.SwitchOAuthToEmail(switchRequest.Email, switchRequest.NewPassword, c.AppContext.Session().UserId)
|
||||
link, err = c.App.SwitchOAuthToEmail(c.AppContext, switchRequest.Email, switchRequest.NewPassword, c.AppContext.Session().UserId)
|
||||
} else if switchRequest.EmailToLdap() {
|
||||
link, err = c.App.SwitchEmailToLdap(c.AppContext, switchRequest.Email, switchRequest.Password, switchRequest.MfaCode, switchRequest.LdapLoginId, switchRequest.NewPassword)
|
||||
} else if switchRequest.LdapToEmail() {
|
||||
@@ -2623,7 +2623,7 @@ func revokeUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = c.App.RevokeUserAccessToken(accessToken); err != nil {
|
||||
if err = c.App.RevokeUserAccessToken(c.AppContext, accessToken); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -2668,7 +2668,7 @@ func disableUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
if err = c.App.DisableUserAccessToken(accessToken); err != nil {
|
||||
if err = c.App.DisableUserAccessToken(c.AppContext, accessToken); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -2713,7 +2713,7 @@ func enableUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = c.App.EnableUserAccessToken(accessToken); err != nil {
|
||||
if err = c.App.EnableUserAccessToken(c.AppContext, accessToken); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user