diff --git a/app/channels.go b/app/channels.go index 7f8ae06944..53a2e74000 100644 --- a/app/channels.go +++ b/app/channels.go @@ -241,6 +241,8 @@ func NewChannels(services map[product.ServiceKey]any) (*Channels, error) { services[product.CommandKey] = &App{ch: ch} + services[product.ThreadsKey] = &App{ch: ch} + return ch, nil } diff --git a/app/collection.go b/app/collection.go index 9b895e3bc0..ad7e4b4029 100644 --- a/app/collection.go +++ b/app/collection.go @@ -10,7 +10,7 @@ import ( "github.com/mattermost/mattermost-server/v6/shared/mlog" ) -func (a *App) registerCollectionAndTopic(pluginID, collectionType, topicType string) error { +func (a *App) RegisterCollectionAndTopic(pluginID, collectionType, topicType string) error { // we have a race condition due to multiple plugins calling this method a.ch.collectionAndTopicTypesMut.Lock() defer a.ch.collectionAndTopicTypesMut.Unlock() diff --git a/app/plugin_api.go b/app/plugin_api.go index 5c8ee9fad1..d1bf97aef1 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -1235,7 +1235,7 @@ func (api *PluginAPI) GetCloudLimits() (*model.ProductLimits, error) { // RegisterCollectionAndTopic informs the server that this plugin handles // the given collection and topic types. func (api *PluginAPI) RegisterCollectionAndTopic(collectionType, topicType string) error { - return api.app.registerCollectionAndTopic(api.id, collectionType, topicType) + return api.app.RegisterCollectionAndTopic(api.id, collectionType, topicType) } func (api *PluginAPI) CreateUploadSession(us *model.UploadSession) (*model.UploadSession, error) { diff --git a/product/api.go b/product/api.go index 64d847d179..272fcd85c0 100644 --- a/product/api.go +++ b/product/api.go @@ -254,3 +254,10 @@ type CommandService interface { ExecuteCommand(c request.CTX, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) RegisterPluginCommand(pluginID string, command *model.Command) error } + +// ThreadsService is the API for interacting with threads anywhere. +// +// The service shall be registered via app.ThreadsKey service key. +type ThreadsService interface { + RegisterCollectionAndTopic(productID string, collectionType, topicType string) error +} diff --git a/product/service.go b/product/service.go index f8100e789b..7e629fc488 100644 --- a/product/service.go +++ b/product/service.go @@ -29,4 +29,5 @@ const ( SessionKey ServiceKey = "sessionkey" FrontendKey ServiceKey = "frontendkey" CommandKey ServiceKey = "commandkey" + ThreadsKey ServiceKey = "threadskey" )