66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
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
|
|
botUserID string
|
|
}
|
|
|
|
func (p *Plugin) OnActivate() error {
|
|
p.API.LogInfo("Activating Sentry plugin...")
|
|
p.sdk = pluginapi.NewClient(p.API, p.Driver)
|
|
|
|
if p.router == nil {
|
|
p.InitApi()
|
|
}
|
|
|
|
if err := p.ensureBot(); err != nil {
|
|
return err
|
|
}
|
|
|
|
configuration := p.GetConfiguration()
|
|
p.configuration = configuration
|
|
|
|
bundlePath, err := p.API.GetBundlePath()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
p.bundlePath = bundlePath
|
|
|
|
if err := p.registerCommands(); err != nil {
|
|
return err
|
|
}
|
|
|
|
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
|
|
}
|