* app: improve plugin interfaces

* add documentation

* improve doc

* add error id

* add more info to readme
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-06-13 09:36:43 +03:00
коммит произвёл GitHub
родитель 7c1b8cd937
Коммит 39991d236b
12 изменённых файлов: 566 добавлений и 10 удалений

Просмотреть файл

@@ -16,6 +16,7 @@ import (
"github.com/mattermost/mattermost-server/v6/einterfaces"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/mattermost/mattermost-server/v6/product"
"github.com/mattermost/mattermost-server/v6/services/imageproxy"
"github.com/mattermost/mattermost-server/v6/shared/filestore"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
@@ -231,6 +232,18 @@ func NewChannels(s *Server, services map[ServiceKey]interface{}) (*Channels, err
app: &App{ch: ch},
}
services[TeamKey] = &teamServiceWrapper{
app: &App{ch: ch},
}
services[BotKey] = &botServiceWrapper{
app: &App{ch: ch},
}
services[HooksKey] = &hooksService{
ch: ch,
}
return ch, nil
}
@@ -307,3 +320,16 @@ func (ch *Channels) RequestTrialLicense(requesterID string, users int, termsAcce
return ch.licenseSvc.RequestTrialLicense(requesterID, users, termsAccepted,
receiveEmailsAccepted)
}
type hooksService struct {
ch *Channels
}
func (s *hooksService) RegisterHooks(productID string, hooks product.Hooks) error {
if s.ch.pluginsEnvironment == nil {
return errors.New("could not find plugins environment")
}
s.ch.pluginsEnvironment.AddProduct(productID, hooks)
return nil
}