Skip to content

Commit

Permalink
[MM-38103] Include professional and enterprise SKUs in license check (m…
Browse files Browse the repository at this point in the history
…attermost#51)

* include professional and enterprise skus in license check

* update source available license

* change license error message

Co-authored-by: Mattermod <[email protected]>
  • Loading branch information
mickmister and mattermod authored Sep 17, 2021
1 parent 285052b commit d0e5b4d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
16 changes: 8 additions & 8 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ With regard to the Mattermost Software:

This software and associated documentation files (the "Software") may only be
used in production, if you (and any entity that you represent) have agreed to,
and are in compliance with, the Mattermost Terms of Service, available at
https://mattermost.com/enterprise-edition-terms/ (the “EE Terms”), or other
agreement governing the use of the Software, as agreed by you and Mattermost,
and otherwise have a valid Mattermost Enterprise E20 subscription for the
correct number of user seats. Subject to the foregoing sentence, you are free
and are in compliance with all of the following: (a) the Mattermost Terms of Service, available at
https://mattermost.com/enterprise-edition-terms/ (the “EE Terms”), (b) any other
agreement(s) governing the use of the Software, as agreed upon by you and Mattermost,
and (c) you otherwise have a valid license or Subscription for the
correct number of Registered Authorized Users of the Software. Subject to the foregoing, you are free
to modify this Software and publish patches to the Software. You agree that
Mattermost and/or its licensors (as applicable) retain all right, title and
interest in and to all such modifications and/or patches, and all such
modifications and/or patches may only be used, copied, modified, displayed,
distributed, or otherwise exploited with a valid Mattermost Enterprise E20
Edition subscription for the correct number of user seats. Notwithstanding
distributed, or otherwise exploited with a valid license or Subscription for the correct number of
Registered Authorized Users of the Software. Notwithstanding
the foregoing, you may copy and modify the Software for development and testing
purposes, without requiring a subscription. You agree that Mattermost and/or
purposes, without requiring a valid license or Subscription. You agree that Mattermost and/or
its licensors (as applicable) retain all right, title and interest in and to
all such modifications. You are not granted any other rights beyond what is
expressly stated herein. Subject to the foregoing, it is forbidden to copy,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mattermost MS Teams Meetings Plugin
# Mattermost MS Teams Meetings Plugin

[![Build Status](https://img.shields.io/circleci/project/github/mattermost/mattermost-plugin-msteams-meetings/master)](https://circleci.com/gh/mattermost/mattermost-plugin-msteams-meetings)
[![Code Coverage](https://img.shields.io/codecov/c/github/mattermost/mattermost-plugin-msteams-meetings/master)](https://codecov.io/gh/mattermost/mattermost-plugin-msteams-meetings)
Expand All @@ -14,7 +14,7 @@ Visit the [MS Teams Meetings documentation](https://mattermost.gitbook.io/micros

## License

This repository is licensed under the [Mattermost Source Available License](LICENSE) and requires a valid Enterprise E20 license. See [Mattermost Source Available License](https://docs.mattermost.com/overview/faq.html#mattermost-source-available-license) to learn more.
This repository is licensed under the [Mattermost Source Available License](LICENSE), and requires a valid Mattermost E20, Professional, or Enterprise license. See our [documentation](https://docs.mattermost.com/about/frequently-asked-questions.html#mattermost-source-available-license) to learn more. If you are contributing to the project, please enable [ServiceSettings.EnableDeveloper](https://docs.mattermost.com/configure/configuration-settings.html#enable-developer-mode) in your server's config. The plugin will not start and show an error message in your server logs, if you are the missing the Enterprise License.


## Development
Expand Down
20 changes: 20 additions & 0 deletions server/license.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
pluginapi "github.com/mattermost/mattermost-plugin-api"
"github.com/mattermost/mattermost-server/v5/model"
)

const (
e20 = "E20"
professional = "professional"
enterprise = "enterprise"
)

func HasEnterpriseFeatures(config *model.Config, license *model.License) bool {
if license != nil && (license.SkuShortName == e20 || license.SkuShortName == enterprise || license.SkuShortName == professional) {
return true
}

return pluginapi.IsE20LicensedOrDevelopment(config, license)
}
9 changes: 4 additions & 5 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/mattermost/mattermost-plugin-msteams-meetings/server/store"

pluginapi "github.com/mattermost/mattermost-plugin-api"
"github.com/mattermost/mattermost-plugin-api/experimental/telemetry"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
Expand All @@ -21,6 +20,8 @@ const (
botUserName = "mstmeetings"
botDisplayName = "MS Teams Meetings"
botDescription = "Created by the MS Teams Meetings plugin."

licenseErrorMessage = "The MS Teams Meetings plugin requires an E20, Professional, or Enterprise license."
)

// Plugin defines the plugin struct
Expand All @@ -45,10 +46,8 @@ type Plugin struct {

// OnActivate checks if the configurations is valid and ensures the bot account exists
func (p *Plugin) OnActivate() error {
pluginAPIClient := pluginapi.NewClient(p.API)

if !pluginapi.IsE20LicensedOrDevelopment(pluginAPIClient.Configuration.GetConfig(), pluginAPIClient.System.GetLicense()) {
return errors.New("a valid Mattermost Enterprise E20 license is required to use this plugin")
if !HasEnterpriseFeatures(p.API.GetConfig(), p.API.GetLicense()) {
return errors.New(licenseErrorMessage)
}

config := p.getConfiguration()
Expand Down

0 comments on commit d0e5b4d

Please sign in to comment.