MM-53358: Revert Threads Everywhere (#23882)
Remove changes related to the unshipped threads everywhere feature, including commitsb8da473da7and9f9e19e05d. Since a version of Playbooks shipped calling this experimental API, keep a `nil` implementation to avoid breaking compatibility. We remove the hooks altogether, but keep the numbering again to avoid breaking compatbility. Fixes: https://mattermost.atlassian.net/browse/MM-53358
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c506e01a97
Коммит
8abc8ed65c
@@ -971,7 +971,6 @@ type AppIface interface {
|
||||
RegenOutgoingWebhookToken(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||
RegenerateOAuthAppSecret(app *model.OAuthApp) (*model.OAuthApp, *model.AppError)
|
||||
RegenerateTeamInviteId(teamID string) (*model.Team, *model.AppError)
|
||||
RegisterCollectionAndTopic(pluginID, collectionType, topicType string) error
|
||||
RegisterPluginCommand(pluginID string, command *model.Command) error
|
||||
RegisterProductCommand(ProductID string, command *model.Command) error
|
||||
ReloadConfig() error
|
||||
|
||||
@@ -83,12 +83,6 @@ type Channels struct {
|
||||
|
||||
postReminderMut sync.Mutex
|
||||
postReminderTask *model.ScheduledTask
|
||||
|
||||
// collectionTypes maps from collection types to the registering plugin id
|
||||
collectionTypes map[string]string
|
||||
// topicTypes maps from topic types to collection types
|
||||
topicTypes map[string]string
|
||||
collectionAndTopicTypesMut sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -111,11 +105,9 @@ func NewChannels(services map[product.ServiceKey]any) (*Channels, error) {
|
||||
return nil, errors.New("server not passed")
|
||||
}
|
||||
ch := &Channels{
|
||||
srv: s,
|
||||
imageProxy: imageproxy.MakeImageProxy(s.platform, s.httpService, s.Log()),
|
||||
uploadLockMap: map[string]bool{},
|
||||
collectionTypes: map[string]string{},
|
||||
topicTypes: map[string]string{},
|
||||
srv: s,
|
||||
imageProxy: imageproxy.MakeImageProxy(s.platform, s.httpService, s.Log()),
|
||||
uploadLockMap: map[string]bool{},
|
||||
}
|
||||
|
||||
// To get another service:
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
// check if collectionType was already registered by other plugin
|
||||
existingPluginID, ok := a.ch.collectionTypes[collectionType]
|
||||
if ok && existingPluginID != pluginID {
|
||||
return model.NewAppError("registerCollectionAndTopic", "app.collection.add_collection.exists.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// check if topicType was already registered to other collection
|
||||
existingCollectionType, ok := a.ch.topicTypes[topicType]
|
||||
if ok && existingCollectionType != collectionType {
|
||||
return model.NewAppError("registerCollectionAndTopic", "app.collection.add_topic.exists.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
a.ch.collectionTypes[collectionType] = pluginID
|
||||
a.ch.topicTypes[topicType] = collectionType
|
||||
|
||||
a.ch.srv.Log().Info("registered collection and topic type", mlog.String("plugin_id", pluginID), mlog.String("collection_type", collectionType), mlog.String("topic_type", topicType))
|
||||
return nil
|
||||
}
|
||||
@@ -13782,28 +13782,6 @@ func (a *OpenTracingAppLayer) RegenerateTeamInviteId(teamID string) (*model.Team
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) RegisterCollectionAndTopic(pluginID string, collectionType string, topicType string) error {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RegisterCollectionAndTopic")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store().SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store().SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.RegisterCollectionAndTopic(pluginID, collectionType, topicType)
|
||||
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) RegisterPluginCommand(pluginID string, command *model.Command) error {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RegisterPluginCommand")
|
||||
|
||||
@@ -462,20 +462,6 @@ func (a *App) DisablePlugin(id string) *model.AppError {
|
||||
}
|
||||
|
||||
func (ch *Channels) disablePlugin(id string) *model.AppError {
|
||||
// find all collectionTypes registered by plugin
|
||||
for collectionTypeToRemove, existingPluginId := range ch.collectionTypes {
|
||||
if existingPluginId != id {
|
||||
continue
|
||||
}
|
||||
// find all topicTypes for existing collectionType
|
||||
for topicTypeToRemove, existingCollectionType := range ch.topicTypes {
|
||||
if existingCollectionType == collectionTypeToRemove {
|
||||
delete(ch.topicTypes, topicTypeToRemove)
|
||||
}
|
||||
}
|
||||
delete(ch.collectionTypes, collectionTypeToRemove)
|
||||
}
|
||||
|
||||
pluginsEnvironment := ch.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return model.NewAppError("DisablePlugin", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
|
||||
@@ -1232,10 +1232,9 @@ func (api *PluginAPI) GetCloudLimits() (*model.ProductLimits, error) {
|
||||
return limits, err
|
||||
}
|
||||
|
||||
// RegisterCollectionAndTopic informs the server that this plugin handles
|
||||
// the given collection and topic types.
|
||||
// RegisterCollectionAndTopic is no longer supported.
|
||||
func (api *PluginAPI) RegisterCollectionAndTopic(collectionType, topicType string) error {
|
||||
return api.app.RegisterCollectionAndTopic(api.id, collectionType, topicType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateUploadSession(us *model.UploadSession) (*model.UploadSession, error) {
|
||||
|
||||
@@ -2019,89 +2019,6 @@ func TestPluginAPIIsEnterpriseReady(t *testing.T) {
|
||||
assert.Equal(t, true, api.IsEnterpriseReady())
|
||||
}
|
||||
|
||||
func TestRegisterCollectionAndTopic(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_THREADSEVERYWHERE", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_THREADSEVERYWHERE")
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.FeatureFlags.ThreadsEverywhere = true
|
||||
})
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
err := api.RegisterCollectionAndTopic("collection1", "topic1")
|
||||
assert.NoError(t, err)
|
||||
err = api.RegisterCollectionAndTopic("collection1", "topic1")
|
||||
assert.NoError(t, err)
|
||||
err = api.RegisterCollectionAndTopic("collection1", "topic2")
|
||||
assert.NoError(t, err)
|
||||
err = api.RegisterCollectionAndTopic("collection2", "topic3")
|
||||
assert.NoError(t, err)
|
||||
err = api.RegisterCollectionAndTopic("collection2", "topic1")
|
||||
assert.Error(t, err)
|
||||
|
||||
pluginCode := `
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
)
|
||||
|
||||
type MyPlugin struct {
|
||||
plugin.MattermostPlugin
|
||||
}
|
||||
|
||||
func (p *MyPlugin) OnActivate() error {
|
||||
if err := p.API.RegisterCollectionAndTopic("collectionTypeToBeRepeated", "some topic"); err != nil {
|
||||
return errors.Wrap(err, "cannot register collection")
|
||||
}
|
||||
if err := p.API.RegisterCollectionAndTopic("some collection", "topicToBeRepeated"); err != nil {
|
||||
return errors.Wrap(err, "cannot register collection")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
plugin.ClientMain(&MyPlugin{})
|
||||
}
|
||||
`
|
||||
pluginDir, err := os.MkdirTemp("", "")
|
||||
require.NoError(t, err)
|
||||
webappPluginDir, err := os.MkdirTemp("", "")
|
||||
require.NoError(t, err)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.Directory = pluginDir
|
||||
*cfg.PluginSettings.ClientDirectory = webappPluginDir
|
||||
})
|
||||
|
||||
newPluginAPI := func(manifest *model.Manifest) plugin.API {
|
||||
return th.App.NewPluginAPI(th.Context, manifest)
|
||||
}
|
||||
|
||||
env, err := plugin.NewEnvironment(newPluginAPI, NewDriverImpl(th.App.Srv()), pluginDir, webappPluginDir, th.App.Log(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
th.App.ch.SetPluginsEnvironment(env)
|
||||
|
||||
pluginID := "testplugin"
|
||||
pluginManifest := `{"id": "testplugin", "server": {"executable": "backend.exe"}}`
|
||||
backend := filepath.Join(pluginDir, pluginID, "backend.exe")
|
||||
utils.CompileGo(t, pluginCode, backend)
|
||||
|
||||
os.WriteFile(filepath.Join(pluginDir, pluginID, "plugin.json"), []byte(pluginManifest), 0600)
|
||||
manifest, activated, reterr := env.Activate(pluginID)
|
||||
require.NoError(t, reterr)
|
||||
require.NotNil(t, manifest)
|
||||
require.True(t, activated)
|
||||
|
||||
err = api.RegisterCollectionAndTopic("collectionTypeToBeRepeated", "some other topic")
|
||||
assert.Error(t, err)
|
||||
err = api.RegisterCollectionAndTopic("some other collection", "topicToBeRepeated")
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestPluginUploadsAPI(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user