[MM-39851] Add CRUD methods for user sessions to plugin API (#18958)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
397edef1d8
Коммит
e8591537e0
@@ -90,16 +90,6 @@ func (api *PluginAPI) ExecuteSlashCommand(commandArgs *model.CommandArgs) (*mode
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetSession(sessionID string) (*model.Session, *model.AppError) {
|
||||
session, err := api.app.GetSessionById(sessionID)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return session, nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetConfig() *model.Config {
|
||||
return api.app.GetSanitizedConfig()
|
||||
}
|
||||
@@ -290,6 +280,22 @@ func (api *PluginAPI) DeletePreferencesForUser(userID string, preferences []mode
|
||||
return api.app.DeletePreferences(userID, preferences)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetSession(sessionID string) (*model.Session, *model.AppError) {
|
||||
return api.app.GetSessionById(sessionID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateSession(session *model.Session) (*model.Session, *model.AppError) {
|
||||
return api.app.CreateSession(session)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) ExtendSessionExpiry(sessionID string, expiresAt int64) *model.AppError {
|
||||
return api.app.extendSessionExpiry(sessionID, expiresAt)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) RevokeSession(sessionID string) *model.AppError {
|
||||
return api.app.RevokeSessionById(sessionID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
||||
return api.app.CreateUserAccessToken(token)
|
||||
}
|
||||
|
||||
@@ -306,6 +306,14 @@ func (a *App) ExtendSessionExpiryIfNeeded(session *model.Session) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *App) extendSessionExpiry(sessionID string, newExpiry int64) *model.AppError {
|
||||
if err := a.Srv().Store.Session().UpdateExpiresAt(sessionID, newExpiry); err != nil {
|
||||
return model.NewAppError("ExtendSessionExpiry", "app.session.extend_session_expiry.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSessionLengthInMillis returns the session length, in milliseconds,
|
||||
// based on the type of session (Mobile, SSO, Web/LDAP).
|
||||
func (a *App) GetSessionLengthInMillis(session *model.Session) int64 {
|
||||
|
||||
Ссылка в новой задаче
Block a user