Use request.CTX instead of *request.Context (#24877)

* Use request.CTX instead of *request.Context

* Fix tests
Этот коммит содержится в:
Ben Schumacher
2023-10-30 16:33:37 +01:00
коммит произвёл GitHub
родитель 37dc35c1a1
Коммит c7461751f2
106 изменённых файлов: 612 добавлений и 613 удалений

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

@@ -19,7 +19,7 @@ func (ps *PlatformService) ReturnSessionToPool(session *model.Session) {
}
}
func (ps *PlatformService) CreateSession(c *request.Context, session *model.Session) (*model.Session, error) {
func (ps *PlatformService) CreateSession(c request.CTX, session *model.Session) (*model.Session, error) {
session.Token = ""
session, err := ps.Store.Session().Save(c, session)
@@ -32,11 +32,11 @@ func (ps *PlatformService) CreateSession(c *request.Context, session *model.Sess
return session, nil
}
func (ps *PlatformService) GetSessionContext(c *request.Context, token string) (*model.Session, error) {
func (ps *PlatformService) GetSessionContext(c request.CTX, token string) (*model.Session, error) {
return ps.Store.Session().Get(c, token)
}
func (ps *PlatformService) GetSessions(c *request.Context, userID string) ([]*model.Session, error) {
func (ps *PlatformService) GetSessions(c request.CTX, userID string) ([]*model.Session, error) {
return ps.Store.Session().GetSessions(c, userID)
}
@@ -96,7 +96,7 @@ func (ps *PlatformService) ClearAllUsersSessionCache() {
}
}
func (ps *PlatformService) GetSession(c *request.Context, token string) (*model.Session, error) {
func (ps *PlatformService) GetSession(c request.CTX, token string) (*model.Session, error) {
var session = ps.sessionPool.Get().(*model.Session)
if err := ps.sessionCache.Get(token, session); err == nil {
if m := ps.metricsIFace; m != nil {
@@ -115,7 +115,7 @@ func (ps *PlatformService) GetSession(c *request.Context, token string) (*model.
return ps.GetSessionContext(c, token)
}
func (ps *PlatformService) GetSessionByID(c *request.Context, sessionID string) (*model.Session, error) {
func (ps *PlatformService) GetSessionByID(c request.CTX, sessionID string) (*model.Session, error) {
return ps.Store.Session().Get(c, sessionID)
}
@@ -134,7 +134,7 @@ func (ps *PlatformService) RevokeSessionsFromAllUsers() error {
return nil
}
func (ps *PlatformService) RevokeSessionsForDeviceId(c *request.Context, userID string, deviceID string, currentSessionId string) error {
func (ps *PlatformService) RevokeSessionsForDeviceId(c request.CTX, userID string, deviceID string, currentSessionId string) error {
sessions, err := ps.Store.Session().GetSessions(c, userID)
if err != nil {
return err
@@ -151,7 +151,7 @@ func (ps *PlatformService) RevokeSessionsForDeviceId(c *request.Context, userID
return nil
}
func (ps *PlatformService) RevokeSession(c *request.Context, session *model.Session) error {
func (ps *PlatformService) RevokeSession(c request.CTX, session *model.Session) error {
if session.IsOAuth {
if err := ps.RevokeAccessToken(c, session.Token); err != nil {
return err
@@ -167,7 +167,7 @@ func (ps *PlatformService) RevokeSession(c *request.Context, session *model.Sess
return nil
}
func (ps *PlatformService) RevokeAccessToken(c *request.Context, token string) error {
func (ps *PlatformService) RevokeAccessToken(c request.CTX, token string) error {
session, _ := ps.GetSession(c, token)
defer ps.ReturnSessionToPool(session)
@@ -222,7 +222,7 @@ func (ps *PlatformService) ExtendSessionExpiry(session *model.Session, newExpiry
return nil
}
func (ps *PlatformService) UpdateSessionsIsGuest(c *request.Context, userID string, isGuest bool) error {
func (ps *PlatformService) UpdateSessionsIsGuest(c request.CTX, userID string, isGuest bool) error {
sessions, err := ps.GetSessions(c, userID)
if err != nil {
return err
@@ -240,7 +240,7 @@ func (ps *PlatformService) UpdateSessionsIsGuest(c *request.Context, userID stri
return nil
}
func (ps *PlatformService) RevokeAllSessions(c *request.Context, userID string) error {
func (ps *PlatformService) RevokeAllSessions(c request.CTX, userID string) error {
sessions, err := ps.Store.Session().GetSessions(c, userID)
if err != nil {
return fmt.Errorf("%s: %w", err.Error(), GetSessionError)