[GH-25492] Add the request context to all public methods in server/channels/app/admin.go (#25498)
Этот коммит содержится в:
@@ -111,23 +111,23 @@ func AddLocalLogs(logData map[string][]string, s *Server, page, perPage int, ser
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) QueryLogs(c request.CTX, page, perPage int, logFilter *model.LogFilter) (map[string][]string, *model.AppError) {
|
||||
return a.Srv().QueryLogs(c, page, perPage, logFilter)
|
||||
func (a *App) QueryLogs(rctx request.CTX, page, perPage int, logFilter *model.LogFilter) (map[string][]string, *model.AppError) {
|
||||
return a.Srv().QueryLogs(rctx, page, perPage, logFilter)
|
||||
}
|
||||
|
||||
func (a *App) GetLogs(c request.CTX, page, perPage int) ([]string, *model.AppError) {
|
||||
return a.Srv().GetLogs(c, page, perPage)
|
||||
func (a *App) GetLogs(rctx request.CTX, page, perPage int) ([]string, *model.AppError) {
|
||||
return a.Srv().GetLogs(rctx, page, perPage)
|
||||
}
|
||||
|
||||
func (s *Server) GetLogsSkipSend(page, perPage int, logFilter *model.LogFilter) ([]string, *model.AppError) {
|
||||
return s.platform.GetLogsSkipSend(page, perPage, logFilter)
|
||||
}
|
||||
|
||||
func (a *App) GetLogsSkipSend(page, perPage int, logFilter *model.LogFilter) ([]string, *model.AppError) {
|
||||
func (a *App) GetLogsSkipSend(rctx request.CTX, page, perPage int, logFilter *model.LogFilter) ([]string, *model.AppError) {
|
||||
return a.Srv().GetLogsSkipSend(page, perPage, logFilter)
|
||||
}
|
||||
|
||||
func (a *App) GetClusterStatus() []*model.ClusterInfo {
|
||||
func (a *App) GetClusterStatus(rctx request.CTX) []*model.ClusterInfo {
|
||||
infos := make([]*model.ClusterInfo, 0)
|
||||
|
||||
if a.Cluster() != nil {
|
||||
@@ -145,18 +145,18 @@ func (s *Server) InvalidateAllCachesSkipSend() {
|
||||
s.platform.InvalidateAllCachesSkipSend()
|
||||
}
|
||||
|
||||
func (a *App) RecycleDatabaseConnection(c request.CTX) {
|
||||
c.Logger().Info("Attempting to recycle database connections.")
|
||||
func (a *App) RecycleDatabaseConnection(rctx request.CTX) {
|
||||
rctx.Logger().Info("Attempting to recycle database connections.")
|
||||
|
||||
// This works by setting 10 seconds as the max conn lifetime for all DB connections.
|
||||
// This allows in gradually closing connections as they expire. In future, we can think
|
||||
// of exposing this as a param from the REST api.
|
||||
a.Srv().Store().RecycleDBConnections(10 * time.Second)
|
||||
|
||||
c.Logger().Info("Finished recycling database connections.")
|
||||
rctx.Logger().Info("Finished recycling database connections.")
|
||||
}
|
||||
|
||||
func (a *App) TestSiteURL(siteURL string) *model.AppError {
|
||||
func (a *App) TestSiteURL(rctx request.CTX, siteURL string) *model.AppError {
|
||||
url := fmt.Sprintf("%s/api/v4/system/ping", siteURL)
|
||||
res, err := http.Get(url)
|
||||
if err != nil || res.StatusCode != 200 {
|
||||
@@ -170,7 +170,7 @@ func (a *App) TestSiteURL(siteURL string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) TestEmail(userID string, cfg *model.Config) *model.AppError {
|
||||
func (a *App) TestEmail(rctx request.CTX, userID string, cfg *model.Config) *model.AppError {
|
||||
if *cfg.EmailSettings.SMTPServer == "" {
|
||||
return model.NewAppError("testEmail", "api.admin.test_email.missing_server", nil, i18n.T("api.context.invalid_param.app_error", map[string]any{"Name": "SMTPServer"}), http.StatusBadRequest)
|
||||
}
|
||||
@@ -201,7 +201,7 @@ func (a *App) TestEmail(userID string, cfg *model.Config) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetLatestVersion(latestVersionUrl string) (*model.GithubReleaseInfo, *model.AppError) {
|
||||
func (a *App) GetLatestVersion(rctx request.CTX, latestVersionUrl string) (*model.GithubReleaseInfo, *model.AppError) {
|
||||
var cachedLatestVersion *model.GithubReleaseInfo
|
||||
if cacheErr := latestVersionCache.Get("latest_version_cache", &cachedLatestVersion); cacheErr == nil {
|
||||
return cachedLatestVersion, nil
|
||||
@@ -237,6 +237,6 @@ func (a *App) GetLatestVersion(latestVersionUrl string) (*model.GithubReleaseInf
|
||||
return releaseInfoResponse, nil
|
||||
}
|
||||
|
||||
func (a *App) ClearLatestVersionCache() {
|
||||
func (a *App) ClearLatestVersionCache(rctx request.CTX) {
|
||||
latestVersionCache.Remove("latest_version_cache")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user