fix: make template build, lint and test cleanly out of the box

This commit is contained in:
2026-09-25 09:05:40 +03:00
parent f3452876da
commit f0e09ef8c9
24 changed files with 128 additions and 244 deletions
+2 -1
View File
@@ -40,7 +40,8 @@ func (p *Plugin) InitApi() {
next.ServeHTTP(w, r)
return
}
http.Error(w, "Not authorized", http.StatusUnauthorized)
w.WriteHeader(http.StatusUnauthorized)
p.sendError(w, "Not authorized")
})
})
+7 -5
View File
@@ -65,11 +65,13 @@ func (p *Plugin) OnConfigurationChange() error {
p.API.LogInfo("OnConfigurationChange")
var configuration = new(Configuration)
// Load the public Configuration fields from the Mattermost server Configuration.
err := p.API.LoadPluginConfiguration(configuration)
if err == nil {
p.SetConfiguration(configuration)
return nil
} else {
if err := p.API.LoadPluginConfiguration(configuration); err != nil {
return errors.Wrap(err, "failed to load plugin Configuration")
}
p.SetConfiguration(configuration)
if err := p.initTelemetry(p.API.GetConfig().LogSettings.EnableDiagnostics); err != nil {
p.API.LogWarn("failed to init telemetry", "error", err.Error())
}
return nil
}
-3
View File
@@ -34,9 +34,6 @@ func (p *Plugin) OnActivate() error {
p.InitApi()
}
configuration := p.GetConfiguration()
p.configuration = configuration
bundlePath, err := p.API.GetBundlePath()
if err != nil {
return err
+6
View File
@@ -17,6 +17,12 @@ func (p *Plugin) uninitTelemetry() error {
}
func (p *Plugin) initTelemetry(enableDiagnostics *bool) error {
// Ключи RudderStack задаются при сборке (MM_RUDDER_CALLS_PROD, MM_RUDDER_DATAPLANE_URL).
// Без них телеметрия просто выключена.
if rudderWriteKey == "" || rudderDataplaneURL == "" {
return nil
}
p.mut.Lock()
defer p.mut.Unlock()
if p.telemetry == nil && enableDiagnostics != nil && *enableDiagnostics {