-
Notifications
You must be signed in to change notification settings - Fork 57
/
license.go
62 lines (48 loc) · 1.82 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2022-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package enterprise
import (
"os"
"github.com/mattermost/mattermost-plugin-calls/server/license"
"github.com/mattermost/mattermost/server/public/model"
)
type LicensePluginAPI interface {
GetLicense() *model.License
GetConfig() *model.Config
}
type LicenseChecker struct {
api LicensePluginAPI
}
func NewLicenseChecker(api LicensePluginAPI) *LicenseChecker {
return &LicenseChecker{
api,
}
}
// isAtLeastE20Licensed returns true when the server either has at least an E20 license or is configured for development.
func (e *LicenseChecker) isAtLeastE20Licensed() bool {
return license.IsE20LicensedOrDevelopment(e.api.GetConfig(), e.api.GetLicense())
}
// isAtLeastE10Licensed returns true when the server either has at least an E10 license or is configured for development.
func (e *LicenseChecker) isAtLeastE10Licensed() bool {
return license.IsE10LicensedOrDevelopment(e.api.GetConfig(), e.api.GetLicense())
}
// RTCDAllowed returns true if the license allows use of an external rtcd service.
func (e *LicenseChecker) RTCDAllowed() bool {
return e.isAtLeastE20Licensed() || license.IsCloud(e.api.GetLicense())
}
// RecordingsAllowed returns true if the license allows use of
// the call recordings functionality.
func (e *LicenseChecker) RecordingsAllowed() bool {
return e.isAtLeastE20Licensed()
}
// RecordingsAllowed returns true if the license allows use of
// the call transcriptions functionality.
func (e *LicenseChecker) TranscriptionsAllowed() bool {
return e.isAtLeastE20Licensed()
}
func (e *LicenseChecker) HostControlsAllowed() bool {
return e.isAtLeastE10Licensed()
}
func (e *LicenseChecker) GroupCallsAllowed() bool {
return e.isAtLeastE10Licensed() || os.Getenv("MM_CALLS_GROUP_CALLS_ALLOWED") == "true"
}