This commit is contained in:
2026-01-30 11:49:04 +03:00
commit f8bb05a652
48 changed files with 9538 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
package plugin
import (
"sync"
"git.wilix.dev/loop/loop-plugin-starter-template/server/telemetry"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost/server/public/plugin"
"github.com/mattermost/mattermost/server/public/pluginapi"
)
var buildHash string
var rudderWriteKey string
var rudderDataplaneURL string
// Plugin implements the interface expected by the Mattermost server to communicate between the server and plugin processes.
type Plugin struct {
plugin.MattermostPlugin
IsReady bool
bundlePath string
configurationLock sync.RWMutex
configuration *Configuration
sdk *pluginapi.Client
router *mux.Router
mut sync.RWMutex
telemetry *telemetry.Client
}
func (p *Plugin) OnActivate() error {
p.API.LogInfo("Activating template plugin...")
p.sdk = pluginapi.NewClient(p.API, p.Driver)
if p.router == nil {
p.InitApi()
}
configuration := p.GetConfiguration()
p.configuration = configuration
bundlePath, err := p.API.GetBundlePath()
if err != nil {
return err
}
p.bundlePath = bundlePath
p.IsReady = true
return nil
}
func (p *Plugin) OnDeactivate() error {
p.API.LogInfo("Deactivating template plugin...")
if err := p.uninitTelemetry(); err != nil {
p.API.LogError(err.Error())
}
return nil
}