Template
fix: make template build, lint and test cleanly out of the box
This commit is contained in:
@@ -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")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user