diff --git a/app/plugin_api.go b/app/plugin_api.go index 6c6b35d3ec..f2e85191ab 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -13,6 +13,7 @@ import ( "net/http" "net/url" "path/filepath" + "strconv" "strings" "github.com/mattermost/mattermost-server/v6/app/request" @@ -141,6 +142,11 @@ func (api *PluginAPI) GetLicense() *model.License { return api.app.Srv().License() } +func (api *PluginAPI) IsEnterpriseReady() bool { + result, _ := strconv.ParseBool(model.BuildEnterpriseReady) + return result +} + func (api *PluginAPI) GetServerVersion() string { return model.CurrentVersion } diff --git a/app/plugin_api_test.go b/app/plugin_api_test.go index 16653f5619..2860aabac1 100644 --- a/app/plugin_api_test.go +++ b/app/plugin_api_test.go @@ -1922,3 +1922,15 @@ func TestPluginAPIUpdateCommand(t *testing.T) { require.Equal(t, team1.Id, newCmd4.TeamId) } + +func TestPluginAPIIsEnterpriseReady(t *testing.T) { + oldValue := model.BuildEnterpriseReady + defer func() { model.BuildEnterpriseReady = oldValue }() + + model.BuildEnterpriseReady = "true" + th := Setup(t) + defer th.TearDown() + api := th.SetupPluginAPI() + + assert.Equal(t, true, api.IsEnterpriseReady()) +} diff --git a/plugin/api.go b/plugin/api.go index 54af3dfdc2..23c1a1bd23 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -92,6 +92,12 @@ type API interface { // Minimum server version: 5.10 GetLicense() *model.License + // IsEnterpriseReady returns true if the Mattermost server is configured as Enterprise Ready. + // + // @tag Server + // Minimum server version: 5.10 + IsEnterpriseReady() bool + // GetServerVersion return the current Mattermost server version // // @tag Server diff --git a/plugin/api_timer_layer_generated.go b/plugin/api_timer_layer_generated.go index 827f60f223..15a4113144 100644 --- a/plugin/api_timer_layer_generated.go +++ b/plugin/api_timer_layer_generated.go @@ -112,6 +112,13 @@ func (api *apiTimerLayer) GetLicense() *model.License { return _returnsA } +func (api *apiTimerLayer) IsEnterpriseReady() bool { + startTime := timePkg.Now() + _returnsA := api.apiImpl.IsEnterpriseReady() + api.recordTime(startTime, "IsEnterpriseReady", true) + return _returnsA +} + func (api *apiTimerLayer) GetServerVersion() string { startTime := timePkg.Now() _returnsA := api.apiImpl.GetServerVersion() diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go index 8901d59aed..68786a8dd4 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -980,6 +980,33 @@ func (s *apiRPCServer) GetLicense(args *Z_GetLicenseArgs, returns *Z_GetLicenseR return nil } +type Z_IsEnterpriseReadyArgs struct { +} + +type Z_IsEnterpriseReadyReturns struct { + A bool +} + +func (g *apiRPCClient) IsEnterpriseReady() bool { + _args := &Z_IsEnterpriseReadyArgs{} + _returns := &Z_IsEnterpriseReadyReturns{} + if err := g.client.Call("Plugin.IsEnterpriseReady", _args, _returns); err != nil { + log.Printf("RPC call to IsEnterpriseReady API failed: %s", err.Error()) + } + return _returns.A +} + +func (s *apiRPCServer) IsEnterpriseReady(args *Z_IsEnterpriseReadyArgs, returns *Z_IsEnterpriseReadyReturns) error { + if hook, ok := s.impl.(interface { + IsEnterpriseReady() bool + }); ok { + returns.A = hook.IsEnterpriseReady() + } else { + return encodableError(fmt.Errorf("API IsEnterpriseReady called but not implemented.")) + } + return nil +} + type Z_GetServerVersionArgs struct { } diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index 39efc94230..888441d528 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -2388,6 +2388,20 @@ func (_m *API) InstallPlugin(file io.Reader, replace bool) (*model.Manifest, *mo return r0, r1 } +// IsEnterpriseReady provides a mock function with given fields: +func (_m *API) IsEnterpriseReady() bool { + ret := _m.Called() + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + // KVCompareAndDelete provides a mock function with given fields: key, oldValue func (_m *API) KVCompareAndDelete(key string, oldValue []byte) (bool, *model.AppError) { ret := _m.Called(key, oldValue)