init
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user