Cloud Freemium - Integrations (#20185)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
54a88fb532
Коммит
ea5bfe3fd9
@@ -156,6 +156,10 @@ func (ch *Channels) syncPluginsActiveState() {
|
||||
if err := ch.notifyPluginStatusesChanged(); err != nil {
|
||||
mlog.Warn("failed to notify plugin status changed", mlog.Err(err))
|
||||
}
|
||||
|
||||
if err := ch.notifyIntegrationsUsageChanged(); err != nil {
|
||||
mlog.Warn("Failed to notify integrations usage changed", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) NewPluginAPI(c *request.Context, manifest *model.Manifest) plugin.API {
|
||||
@@ -370,6 +374,11 @@ func (a *App) GetActivePluginManifests() ([]*model.Manifest, *model.AppError) {
|
||||
// activation if inactive anywhere in the cluster.
|
||||
// Notifies cluster peers through config change.
|
||||
func (a *App) EnablePlugin(id string) *model.AppError {
|
||||
appErr := a.checkIfIntegrationsMeetFreemiumLimits([]string{id})
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
|
||||
return a.ch.enablePlugin(id)
|
||||
}
|
||||
|
||||
@@ -416,7 +425,12 @@ func (ch *Channels) enablePlugin(id string) *model.AppError {
|
||||
// DisablePlugin will set the config for an installed plugin to disabled, triggering deactivation if active.
|
||||
// Notifies cluster peers through config change.
|
||||
func (a *App) DisablePlugin(id string) *model.AppError {
|
||||
return a.ch.disablePlugin(id)
|
||||
appErr := a.ch.disablePlugin(id)
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ch *Channels) disablePlugin(id string) *model.AppError {
|
||||
@@ -457,6 +471,20 @@ func (ch *Channels) disablePlugin(id string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ch *Channels) notifyIntegrationsUsageChanged() *model.AppError {
|
||||
usage, appErr := ch.getIntegrationsUsage()
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WebsocketEventIntegrationsUsageChanged, "", "", "", nil)
|
||||
message.Add("usage", usage)
|
||||
message.GetBroadcast().ContainsSensitiveData = true
|
||||
ch.Publish(message)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) GetPlugins() (*model.PluginsResponse, *model.AppError) {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
@@ -1064,12 +1092,12 @@ func getIcon(iconPath string) (string, error) {
|
||||
|
||||
func (ch *Channels) getPluginStateOverride(pluginID string) (bool, bool) {
|
||||
switch pluginID {
|
||||
case "com.mattermost.apps":
|
||||
case model.PluginIdApps:
|
||||
// Tie Apps proxy disabled status to the feature flag.
|
||||
if !ch.cfgSvc.Config().FeatureFlags.AppsEnabled {
|
||||
return true, false
|
||||
}
|
||||
case "com.mattermost.calls":
|
||||
case model.PluginIdCalls:
|
||||
if model.IsCloud() {
|
||||
return true, ch.cfgSvc.Config().FeatureFlags.CallsEnabled
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user