mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fix all occurances of checking for RemoteClusterServiceLicense (#22453)
This commit is contained in:
@@ -579,7 +579,7 @@ func (s *Server) startInterClusterServices(license *model.License) error {
|
||||
// Remote Cluster service
|
||||
|
||||
// License check (assume enabled if shared channels enabled)
|
||||
if !*license.Features.RemoteClusterService && !license.HasSharedChannels() {
|
||||
if !license.HasRemoteClusterService() && !license.HasSharedChannels() {
|
||||
mlog.Debug("License does not have Remote Cluster services enabled")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -321,6 +321,21 @@ func (l *License) HasEnterpriseMarketplacePlugins() bool {
|
||||
l.SkuShortName == LicenseShortSkuEnterprise
|
||||
}
|
||||
|
||||
func (l *License) HasRemoteClusterService() bool {
|
||||
if l == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// If SharedChannels is enabled then RemoteClusterService must be enabled.
|
||||
if l.HasSharedChannels() {
|
||||
return true
|
||||
}
|
||||
|
||||
return (l.Features != nil && l.Features.RemoteClusterService != nil && *l.Features.RemoteClusterService) ||
|
||||
l.SkuShortName == LicenseShortSkuProfessional ||
|
||||
l.SkuShortName == LicenseShortSkuEnterprise
|
||||
}
|
||||
|
||||
func (l *License) HasSharedChannels() bool {
|
||||
if l == nil {
|
||||
return false
|
||||
|
||||
@@ -145,7 +145,7 @@ func (c *Context) CloudKeyRequired() {
|
||||
}
|
||||
|
||||
func (c *Context) RemoteClusterTokenRequired() {
|
||||
if license := c.App.Channels().License(); license == nil || !*license.Features.RemoteClusterService || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeRemoteclusterToken {
|
||||
if license := c.App.Channels().License(); license == nil || !license.HasRemoteClusterService() || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeRemoteclusterToken {
|
||||
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "TokenRequired", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
c.AppContext.SetSession(session)
|
||||
}
|
||||
} else if token != "" && c.App.Channels().License() != nil && *c.App.Channels().License().Features.RemoteClusterService && tokenLocation == app.TokenLocationRemoteClusterHeader {
|
||||
} else if token != "" && c.App.Channels().License() != nil && c.App.Channels().License().HasRemoteClusterService() && tokenLocation == app.TokenLocationRemoteClusterHeader {
|
||||
// Get the remote cluster
|
||||
if remoteId := c.GetRemoteID(r); remoteId == "" {
|
||||
c.Logger.Warn("Missing remote cluster id") //
|
||||
|
||||
Reference in New Issue
Block a user