Only pull active plugins from the mattermost marketplace.
Этот коммит содержится в:
@@ -17,6 +17,34 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/utils"
|
||||
)
|
||||
|
||||
func pluginActivated(pluginStates map[string]*model.PluginState, pluginId string) bool {
|
||||
state, ok := pluginStates[pluginId]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return state.Enable
|
||||
}
|
||||
|
||||
func (a *App) getMarketplacePlugins() ([]string, error) {
|
||||
ts := a.Srv().telemetryService
|
||||
config := a.Srv().Config()
|
||||
|
||||
marketplacePlugins, err := ts.GetAllMarketplacePlugins(model.PluginSettingsDefaultMarketplaceURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
activePlugins := []string{}
|
||||
for _, p := range marketplacePlugins {
|
||||
id := p.Manifest.Id
|
||||
if pluginActivated(config.PluginSettings.PluginStates, id) {
|
||||
activePlugins = append(activePlugins, id)
|
||||
}
|
||||
}
|
||||
|
||||
return activePlugins, nil
|
||||
}
|
||||
|
||||
func (a *App) getTrueUpProfile() (*model.TrueUpReviewProfile, error) {
|
||||
|
||||
license := a.Channels().License()
|
||||
@@ -42,20 +70,12 @@ func (a *App) getTrueUpProfile() (*model.TrueUpReviewProfile, error) {
|
||||
|
||||
// Plugin Data
|
||||
trueUpReviewPlugins := model.TrueUpReviewPlugins{
|
||||
ActivePluginNames: []string{},
|
||||
InactivePluginNames: []string{},
|
||||
PluginNames: []string{},
|
||||
}
|
||||
|
||||
if pluginResponse, err := a.GetPlugins(); err == nil {
|
||||
for _, plugin := range pluginResponse.Active {
|
||||
trueUpReviewPlugins.ActivePluginNames = append(trueUpReviewPlugins.ActivePluginNames, plugin.Name)
|
||||
}
|
||||
trueUpReviewPlugins.TotalActivePlugins = len(trueUpReviewPlugins.ActivePluginNames)
|
||||
|
||||
for _, plugin := range pluginResponse.Inactive {
|
||||
trueUpReviewPlugins.InactivePluginNames = append(trueUpReviewPlugins.InactivePluginNames, plugin.Name)
|
||||
}
|
||||
trueUpReviewPlugins.TotalInactivePlugins = len(trueUpReviewPlugins.InactivePluginNames)
|
||||
if plugins, err := a.getMarketplacePlugins(); err == nil {
|
||||
trueUpReviewPlugins.PluginNames = plugins
|
||||
trueUpReviewPlugins.TotalPlugins = len(plugins)
|
||||
}
|
||||
|
||||
// Authentication Features
|
||||
|
||||
@@ -21,18 +21,14 @@ type TrueUpReviewProfile struct {
|
||||
}
|
||||
|
||||
type TrueUpReviewPlugins struct {
|
||||
TotalActivePlugins int `json:"total_active_plugins"`
|
||||
TotalInactivePlugins int `json:"total_inactive_plugins"`
|
||||
ActivePluginNames []string `json:"active_plugin_names"`
|
||||
InactivePluginNames []string `json:"inactive_plugin_names"`
|
||||
TotalPlugins int `json:"total_plugins"`
|
||||
PluginNames []string `json:"plugin_names"`
|
||||
}
|
||||
|
||||
func (t *TrueUpReviewPlugins) ToMap() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"total_active_plugins": t.TotalActivePlugins,
|
||||
"total_inactive_plugins": t.TotalInactivePlugins,
|
||||
"active_plugin_names": strings.Join(t.ActivePluginNames, ","),
|
||||
"inactive_plugin_names": strings.Join(t.InactivePluginNames, ","),
|
||||
"total_plugins": t.TotalPlugins,
|
||||
"plugin_names": strings.Join(t.PluginNames, ","),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1418,7 +1418,7 @@ func (ts *TelemetryService) trackPluginConfig(cfg *model.Config, marketplaceURL
|
||||
"focalboard",
|
||||
}
|
||||
|
||||
marketplacePlugins, err := ts.getAllMarketplaceplugins(marketplaceURL)
|
||||
marketplacePlugins, err := ts.GetAllMarketplacePlugins(marketplaceURL)
|
||||
if err != nil {
|
||||
mlog.Info("Failed to fetch marketplace plugins for telemetry. Using predefined list.", mlog.Err(err))
|
||||
|
||||
@@ -1456,7 +1456,7 @@ func (ts *TelemetryService) trackPluginConfig(cfg *model.Config, marketplaceURL
|
||||
ts.SendTelemetry(TrackConfigPlugin, pluginConfigData)
|
||||
}
|
||||
|
||||
func (ts *TelemetryService) getAllMarketplaceplugins(marketplaceURL string) ([]*model.BaseMarketplacePlugin, error) {
|
||||
func (ts *TelemetryService) GetAllMarketplacePlugins(marketplaceURL string) ([]*model.BaseMarketplacePlugin, error) {
|
||||
marketplaceClient, err := marketplace.NewClient(
|
||||
marketplaceURL,
|
||||
ts.srv.HTTPService(),
|
||||
|
||||
Ссылка в новой задаче
Block a user