[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 <mattermod@users.noreply.github.com>
This commit is contained in:
Michael Kochell
2021-08-24 14:37:58 -04:00
committed by GitHub
parent 6031b163d8
commit eaa37b52ee
2 changed files with 13 additions and 1 deletions

View File

@@ -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
}

View File

@@ -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{