forked from mattermost/mattermost-plugin-jira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
license.go
42 lines (33 loc) · 859 Bytes
/
license.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package enterprise
import (
pluginapi "github.com/mattermost/mattermost-plugin-api"
"github.com/mattermost/mattermost-server/v6/model"
)
type Checker interface {
HasEnterpriseFeatures() bool
}
type enterpriseChecker struct {
api PluginAPI
}
type PluginAPI interface {
GetLicense() *model.License
GetConfig() *model.Config
}
func NewEnterpriseChecker(api PluginAPI) Checker {
return &enterpriseChecker{
api: api,
}
}
const (
e20 = "E20"
professional = "professional"
enterprise = "enterprise"
)
func (e *enterpriseChecker) HasEnterpriseFeatures() bool {
config := e.api.GetConfig()
license := e.api.GetLicense()
if license != nil && (license.SkuShortName == e20 || license.SkuShortName == enterprise || license.SkuShortName == professional) {
return true
}
return pluginapi.IsE20LicensedOrDevelopment(config, license)
}