-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MM-44651] Implement MaxCallParticipants
config setting
#93
Changes from all commits
dc0154b
94d9396
b25d752
3548002
ad4b096
abfb43a
894f444
36c67f6
2c60467
f2e408f
bceab79
8533208
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ package main | |
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
"reflect" | ||
"strconv" | ||
"strings" | ||
|
@@ -44,6 +45,9 @@ type clientConfig struct { | |
AllowEnableCalls *bool | ||
// When set to true, calls will be possible in all channels where they are not explicitly disabled. | ||
DefaultEnabled *bool | ||
// The maximum number of participants that can join a call. The zero value | ||
// means unlimited. | ||
MaxCallParticipants *int | ||
} | ||
|
||
type ICEServers []string | ||
|
@@ -107,9 +111,10 @@ func (pr PortsRange) IsValid() error { | |
|
||
func (c *configuration) getClientConfig() clientConfig { | ||
return clientConfig{ | ||
AllowEnableCalls: c.AllowEnableCalls, | ||
DefaultEnabled: c.DefaultEnabled, | ||
ICEServers: c.ICEServers, | ||
AllowEnableCalls: c.AllowEnableCalls, | ||
DefaultEnabled: c.DefaultEnabled, | ||
ICEServers: c.ICEServers, | ||
MaxCallParticipants: c.MaxCallParticipants, | ||
} | ||
} | ||
|
||
|
@@ -124,6 +129,9 @@ func (c *configuration) SetDefaults() { | |
c.DefaultEnabled = new(bool) | ||
*c.DefaultEnabled = false | ||
} | ||
if c.MaxCallParticipants == nil { | ||
c.MaxCallParticipants = new(int) | ||
} | ||
} | ||
|
||
func (c *configuration) IsValid() error { | ||
|
@@ -135,6 +143,10 @@ func (c *configuration) IsValid() error { | |
return fmt.Errorf("UDPServerPort is not valid: %d is not in allowed range [1024, 49151]", *c.UDPServerPort) | ||
} | ||
|
||
if c.MaxCallParticipants == nil || *c.MaxCallParticipants < 0 { | ||
return fmt.Errorf("MaxCallParticipants is not valid") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
@@ -165,6 +177,10 @@ func (c *configuration) Clone() *configuration { | |
} | ||
} | ||
|
||
if c.MaxCallParticipants != nil { | ||
cfg.MaxCallParticipants = model.NewInt(*c.MaxCallParticipants) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question for myself: why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I feel like Hamlet now 💀 Part of me wants to avoid relying on |
||
} | ||
|
||
return &cfg | ||
} | ||
|
||
|
@@ -196,6 +212,10 @@ func (p *Plugin) setConfiguration(configuration *configuration) error { | |
p.configurationLock.Lock() | ||
defer p.configurationLock.Unlock() | ||
|
||
if p.configuration == nil && configuration != nil { | ||
p.setOverrides(configuration) | ||
} | ||
|
||
if configuration != nil && p.configuration == configuration { | ||
// Ignore assignment if the configuration struct is empty. Go will optimize the | ||
// allocation for same to point at the same memory address, breaking the check | ||
|
@@ -234,9 +254,32 @@ func (p *Plugin) OnConfigurationChange() error { | |
return fmt.Errorf("OnConfigurationChange: failed to load plugin configuration: %w", err) | ||
} | ||
|
||
// Permanently override with envVar and cloud overrides | ||
p.setOverrides(cfg) | ||
|
||
return p.setConfiguration(cfg) | ||
} | ||
|
||
func (p *Plugin) setOverrides(cfg *configuration) { | ||
if license := p.API.GetLicense(); license != nil && isCloud(license) { | ||
// On Cloud installations we want calls enabled in all channels so we | ||
// override it since the plugin's default is now false. | ||
*cfg.DefaultEnabled = true | ||
} | ||
|
||
// Allow env var to permanently override system console settings | ||
if maxPart := os.Getenv("MM_CALLS_MAX_PARTICIPANTS"); maxPart != "" { | ||
if max, err := strconv.Atoi(maxPart); err == nil { | ||
*cfg.MaxCallParticipants = max | ||
} else { | ||
p.LogError("setOverrides", "failed to parse MM_CALLS_MAX_PARTICIPANTS", err.Error()) | ||
} | ||
} else if license := p.API.GetLicense(); license != nil && isCloud(license) { | ||
// otherwise, if this is a cloud installation, set it at the default | ||
*cfg.MaxCallParticipants = cloudMaxParticipantsDefault | ||
} | ||
} | ||
|
||
func (p *Plugin) isHAEnabled() bool { | ||
cfg := p.API.GetConfig() | ||
return cfg != nil && cfg.ClusterSettings.Enable != nil && *cfg.ClusterSettings.Enable | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is a breaking change but given it only affects Cloud I think we can safely make it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think... Good thing mobile isn't cut yet. :)