From eaa37b52ee5a55ca0739d55e2b9c64e2663d353c Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Tue, 24 Aug 2021 14:37:58 -0400 Subject: [PATCH] [MM-37494] Check for license SKU when preparing marketplace requests (#18031) * check for license SKU when preparing marketplace requests * rename method to HasEnterpriseMarketplacePlugins Co-authored-by: Mattermod --- app/plugin.go | 2 +- model/license.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/plugin.go b/app/plugin.go index 2791d887a3..02e73b6543 100644 --- a/app/plugin.go +++ b/app/plugin.go @@ -720,7 +720,7 @@ func (s *Server) getBaseMarketplaceFilter() *model.MarketplacePluginFilter { } license := s.License() - if license != nil && *license.Features.EnterprisePlugins { + if license != nil && license.HasEnterpriseMarketplacePlugins() { filter.EnterprisePlugins = true } diff --git a/model/license.go b/model/license.go index d424a6d39d..cbdcf6d38c 100644 --- a/model/license.go +++ b/model/license.go @@ -16,6 +16,11 @@ const ( InvalidLicenseError = "api.license.add_license.invalid.app_error" LicenseGracePeriod = 1000 * 60 * 60 * 24 * 10 //10 days LicenseRenewalLink = "https://mattermost.com/renew/" + + LicenseShortSkuE10 = "E10" + LicenseShortSkuE20 = "E20" + LicenseShortSkuProfessional = "professional" + LicenseShortSkuEnterprise = "enterprise" ) const ( @@ -302,6 +307,13 @@ func (l *License) IsSanctionedTrial() bool { (duration >= sanctionedTrialDurationLowerBound.Milliseconds() || duration <= sanctionedTrialDurationUpperBound.Milliseconds()) } +func (l *License) HasEnterpriseMarketplacePlugins() bool { + return *l.Features.EnterprisePlugins || + l.SkuShortName == LicenseShortSkuE20 || + l.SkuShortName == LicenseShortSkuProfessional || + l.SkuShortName == LicenseShortSkuEnterprise +} + // NewTestLicense returns a license that expires in the future and has the given features. func NewTestLicense(features ...string) *License { ret := &License{