Cloud Freemium - Integrations (#20185)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
54a88fb532
Коммит
ea5bfe3fd9
35
app/usage.go
35
app/usage.go
@@ -10,6 +10,41 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/utils"
|
||||
)
|
||||
|
||||
// CheckFreemiumLimitsForConfigSave returns an error if the configuration being saved violates the Cloud Freemium limits
|
||||
func (a *App) CheckFreemiumLimitsForConfigSave(oldConfig, newConfig *model.Config) *model.AppError {
|
||||
if !a.Config().FeatureFlags.CloudFree {
|
||||
return nil
|
||||
}
|
||||
|
||||
appErr := a.checkIntegrationLimitsForConfigSave(oldConfig, newConfig)
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetIntegrationsUsage returns usage information on enabled integrations
|
||||
func (a *App) GetIntegrationsUsage() (*model.IntegrationsUsage, *model.AppError) {
|
||||
return a.ch.getIntegrationsUsage()
|
||||
}
|
||||
|
||||
func (ch *Channels) getIntegrationsUsage() (*model.IntegrationsUsage, *model.AppError) {
|
||||
installed, appErr := ch.getInstalledIntegrations()
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
var count = 0
|
||||
for _, i := range installed {
|
||||
if i.Enabled {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
return &model.IntegrationsUsage{Enabled: count}, nil
|
||||
}
|
||||
|
||||
// GetPostsUsage returns "rounded off" total posts count like returns 900 instead of 987
|
||||
func (a *App) GetPostsUsage() (int64, *model.AppError) {
|
||||
count, err := a.Srv().Store.Post().AnalyticsPostCount(&model.PostCountOptions{ExcludeDeleted: true})
|
||||
|
||||
Ссылка в новой задаче
Block a user