Invalidate cloud caches when a new license is loaded (#21579)

Automatic Merge
Этот коммит содержится в:
Nick Misasi
2022-11-02 16:40:26 -04:00
коммит произвёл GitHub
родитель 1ae97fc381
Коммит a541cda9d0
19 изменённых файлов: 69 добавлений и 43 удалений

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

@@ -1348,7 +1348,7 @@ func (a *App) ExtractContentFromFileInfo(fileInfo *model.FileInfo) error {
// GetLastAccessibleFileTime returns CreateAt time(from cache) of the last accessible post as per the cloud limit
func (a *App) GetLastAccessibleFileTime() (int64, *model.AppError) {
license := a.Srv().License()
if license == nil || !*license.Features.Cloud {
if !license.IsCloud() {
return 0, nil
}
@@ -1403,7 +1403,7 @@ func (a *App) ComputeLastAccessibleFileTime() error {
// getCloudFilesSizeLimit returns size in bytes
func (a *App) getCloudFilesSizeLimit() (int64, *model.AppError) {
license := a.Srv().License()
if license == nil || !*license.Features.Cloud {
if license == nil || !license.IsCloud() {
return 0, nil
}

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

@@ -70,7 +70,7 @@ func (ch *Channels) getInstalledIntegrations() ([]*model.InstalledIntegration, *
}
func (a *App) checkIfIntegrationsMeetFreemiumLimits(originalPluginIds []string) *model.AppError {
if a.License() == nil || !*a.License().Features.Cloud {
if !a.License().IsCloud() {
return nil
}

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

@@ -333,7 +333,7 @@ func (a *App) AttachSessionCookies(c *request.Context, w http.ResponseWriter, r
http.SetCookie(w, csrfCookie)
// For context see: https://mattermost.atlassian.net/browse/MM-39583
if a.Channels().License() != nil && *a.Channels().License().Features.Cloud {
if a.License().IsCloud() {
a.AttachCloudSessionCookie(c, w, r)
}
}
@@ -346,5 +346,5 @@ func GetProtocol(r *http.Request) string {
}
func IsCWSLogin(a *App, token string) bool {
return a.Srv().License() != nil && *a.Srv().License().Features.Cloud && token != ""
return a.License().IsCloud() && token != ""
}

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

@@ -338,7 +338,7 @@ func (ps *PlatformService) GenerateRenewalToken(expiration time.Duration) (strin
return "", model.NewAppError("GenerateRenewalToken", "app.license.generate_renewal_token.no_license", nil, "", http.StatusBadRequest)
}
if *license.Features.Cloud {
if license.IsCloud() {
return "", model.NewAppError("GenerateRenewalToken", "app.license.generate_renewal_token.bad_license", nil, "", http.StatusBadRequest)
}

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

@@ -586,7 +586,7 @@ func (a *App) GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*m
// This is a short term fix. The long term solution is to have a separate set of
// prepacked plugins for cloud: https://mattermost.atlassian.net/browse/MM-31331.
license := a.Srv().License()
if license == nil || !*license.Features.Cloud {
if license == nil || !license.IsCloud() {
appErr := a.mergePrepackagedPlugins(plugins)
if appErr != nil {
return nil, appErr
@@ -813,7 +813,7 @@ func (ch *Channels) getBaseMarketplaceFilter() *model.MarketplacePluginFilter {
filter.EnterprisePlugins = true
}
if license != nil && *license.Features.Cloud {
if license != nil && license.IsCloud() {
filter.Cloud = true
}

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

@@ -1408,7 +1408,7 @@ func (a *App) convertUserNameToUserIds(usernames []string) []string {
// GetLastAccessiblePostTime returns CreateAt time(from cache) of the last accessible post as per the cloud limit
func (a *App) GetLastAccessiblePostTime() (int64, *model.AppError) {
license := a.Srv().License()
if license == nil || !*license.Features.Cloud {
if license == nil || !license.IsCloud() {
return 0, nil
}
@@ -1467,7 +1467,7 @@ func (a *App) ComputeLastAccessiblePostTime() error {
func (a *App) getCloudMessagesHistoryLimit() (int64, *model.AppError) {
license := a.Srv().License()
if license == nil || !*license.Features.Cloud {
if license == nil || !license.IsCloud() {
return 0, nil
}

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

@@ -1347,7 +1347,7 @@ func (s *Server) doLicenseExpirationCheck() {
return
}
if *license.Features.Cloud {
if license.IsCloud() {
mlog.Debug("Skipping license expiration check for Cloud")
return
}