-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathlicense.go
48 lines (36 loc) · 1.57 KB
/
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
43
44
45
46
47
48
// Copyright (c) 2023-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.enterprise for license information.
package enterprise
import (
"errors"
"github.com/mattermost/mattermost/server/public/pluginapi"
)
var ErrNotLicensed = errors.New("license does not support this feature")
type LicenseChecker struct {
pluginAPIClient *pluginapi.Client
}
func NewLicenseChecker(pluginAPIClient *pluginapi.Client) *LicenseChecker {
return &LicenseChecker{
pluginAPIClient,
}
}
// isAtLeastE20Licensed returns true when the server either has an E20 license or is configured for development.
func (e *LicenseChecker) isAtLeastE20Licensed() bool {
config := e.pluginAPIClient.Configuration.GetConfig()
license := e.pluginAPIClient.System.GetLicense()
return pluginapi.IsE20LicensedOrDevelopment(config, license)
}
// isAtLeastE10Licensed returns true when the server either has at least an E10 license or is configured for development.
func (e *LicenseChecker) isAtLeastE10Licensed() bool { //nolint:unused
config := e.pluginAPIClient.Configuration.GetConfig()
license := e.pluginAPIClient.System.GetLicense()
return pluginapi.IsE10LicensedOrDevelopment(config, license)
}
// IsMultiLLMLicensed returns true when the server either has a multi-LLM license or is configured for development.
func (e *LicenseChecker) IsMultiLLMLicensed() bool {
return e.isAtLeastE20Licensed()
}
// IsBasicsLicensed returns true when the server either has a license for basic features or is configured for development.
func (e *LicenseChecker) IsBasicsLicensed() bool {
return e.isAtLeastE20Licensed()
}