mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-27 08:41:57 -06:00
Remove "magic" Enabled function and use simple bool
This commit is contained in:
parent
26accb8c5d
commit
74da1f0fb3
|
@ -699,7 +699,7 @@ func handleApplicationServiceRegistration(
|
||||||
}
|
}
|
||||||
|
|
||||||
policyVersion := ""
|
policyVersion := ""
|
||||||
if cfg.Matrix.UserConsentOptions.Enabled() {
|
if cfg.Matrix.UserConsentOptions.Enabled {
|
||||||
policyVersion = cfg.Matrix.UserConsentOptions.Version
|
policyVersion = cfg.Matrix.UserConsentOptions.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,7 +725,7 @@ func checkAndCompleteFlow(
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if checkFlowCompleted(flow, cfg.Derived.Registration.Flows) {
|
if checkFlowCompleted(flow, cfg.Derived.Registration.Flows) {
|
||||||
policyVersion := ""
|
policyVersion := ""
|
||||||
if cfg.Matrix.UserConsentOptions.Enabled() {
|
if cfg.Matrix.UserConsentOptions.Enabled {
|
||||||
policyVersion = cfg.Matrix.UserConsentOptions.Version
|
policyVersion = cfg.Matrix.UserConsentOptions.Version
|
||||||
}
|
}
|
||||||
// This flow was completed, registration can continue
|
// This flow was completed, registration can continue
|
||||||
|
|
|
@ -118,7 +118,7 @@ func Setup(
|
||||||
}
|
}
|
||||||
|
|
||||||
// unspecced consent tracking
|
// unspecced consent tracking
|
||||||
if cfg.Matrix.UserConsentOptions.Enabled() {
|
if cfg.Matrix.UserConsentOptions.Enabled {
|
||||||
consentAPIMux.Handle("/consent",
|
consentAPIMux.Handle("/consent",
|
||||||
httputil.MakeHTMLAPI("consent", func(writer http.ResponseWriter, request *http.Request) *util.JSONResponse {
|
httputil.MakeHTMLAPI("consent", func(writer http.ResponseWriter, request *http.Request) *util.JSONResponse {
|
||||||
return consent(writer, request, userAPI, cfg)
|
return consent(writer, request, userAPI, cfg)
|
||||||
|
|
|
@ -82,7 +82,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
policyVersion := ""
|
policyVersion := ""
|
||||||
if cfg.Global.UserConsentOptions.Enabled() {
|
if cfg.Global.UserConsentOptions.Enabled {
|
||||||
policyVersion = cfg.Global.UserConsentOptions.Version
|
policyVersion = cfg.Global.UserConsentOptions.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,9 +69,9 @@ global:
|
||||||
disable_federation: false
|
disable_federation: false
|
||||||
|
|
||||||
# Consent tracking configuration
|
# Consent tracking configuration
|
||||||
# If either require_at_registration or send_server_notice_to_guest are true, consent
|
|
||||||
# messages will be sent to the users.
|
|
||||||
user_consent:
|
user_consent:
|
||||||
|
# If the user consent tracking is enabled or not
|
||||||
|
enabled: false
|
||||||
# Randomly generated string to be used to calculate the HMAC
|
# Randomly generated string to be used to calculate the HMAC
|
||||||
form_secret: "superSecretRandomlyGeneratedSecret"
|
form_secret: "superSecretRandomlyGeneratedSecret"
|
||||||
# Require consent when user registers for the first time
|
# Require consent when user registers for the first time
|
||||||
|
|
|
@ -87,7 +87,7 @@ func MakeAuthAPI(
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if userConsentCfg.Enabled() && requireConsent {
|
if userConsentCfg.Enabled && requireConsent {
|
||||||
consentError := checkConsent(req.Context(), device.UserID, userAPI, userConsentCfg)
|
consentError := checkConsent(req.Context(), device.UserID, userAPI, userConsentCfg)
|
||||||
if consentError != nil {
|
if consentError != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
|
|
@ -213,6 +213,8 @@ func (c *DNSCacheOptions) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||||
// If either require_at_registration or send_server_notice_to_guest are true, consent
|
// If either require_at_registration or send_server_notice_to_guest are true, consent
|
||||||
// messages will be sent to the users.
|
// messages will be sent to the users.
|
||||||
type UserConsentOptions struct {
|
type UserConsentOptions struct {
|
||||||
|
// If consent tracking is enabled or not
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
// Randomly generated string to be used to calculate the HMAC
|
// Randomly generated string to be used to calculate the HMAC
|
||||||
FormSecret string `yaml:"form_secret"`
|
FormSecret string `yaml:"form_secret"`
|
||||||
// Require consent when user registers for the first time
|
// Require consent when user registers for the first time
|
||||||
|
@ -241,6 +243,7 @@ type UserConsentOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConsentOptions) Defaults(baseURL string) {
|
func (c *UserConsentOptions) Defaults(baseURL string) {
|
||||||
|
c.Enabled = false
|
||||||
c.RequireAtRegistration = false
|
c.RequireAtRegistration = false
|
||||||
c.SendServerNoticeToGuest = false
|
c.SendServerNoticeToGuest = false
|
||||||
c.PolicyName = "Privacy Policy"
|
c.PolicyName = "Privacy Policy"
|
||||||
|
@ -250,7 +253,7 @@ func (c *UserConsentOptions) Defaults(baseURL string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConsentOptions) Verify(configErrors *ConfigErrors, isMonolith bool) {
|
func (c *UserConsentOptions) Verify(configErrors *ConfigErrors, isMonolith bool) {
|
||||||
if c.Enabled() {
|
if c.Enabled {
|
||||||
checkNotEmpty(configErrors, "template_dir", c.TemplateDir)
|
checkNotEmpty(configErrors, "template_dir", c.TemplateDir)
|
||||||
checkNotEmpty(configErrors, "version", c.Version)
|
checkNotEmpty(configErrors, "version", c.Version)
|
||||||
checkNotEmpty(configErrors, "policy_name", c.PolicyName)
|
checkNotEmpty(configErrors, "policy_name", c.PolicyName)
|
||||||
|
@ -281,7 +284,3 @@ func (c *UserConsentOptions) Verify(configErrors *ConfigErrors, isMonolith bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConsentOptions) Enabled() bool {
|
|
||||||
return c.RequireAtRegistration || c.SendServerNoticeToGuest
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue