diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2021-09-23 07:13:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 07:13:34 -0400 |
commit | e584534403b55ad3f250f92592e30b15b01f0201 (patch) | |
tree | 5561c7ba12f99eb72531b5b7ad3d60c7cd306b54 /synapse/rest/consent | |
parent | Remove unnecessary parentheses around tuples returned from methods (#10889) (diff) | |
download | synapse-e584534403b55ad3f250f92592e30b15b01f0201.tar.xz |
Use direct references for some configuration variables (part 3) (#10885)
This avoids the overhead of searching through the various configuration classes by directly referencing the class that the attributes are in. It also improves type hints since mypy can now resolve the types of the configuration variables.
Diffstat (limited to 'synapse/rest/consent')
-rw-r--r-- | synapse/rest/consent/consent_resource.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/synapse/rest/consent/consent_resource.py b/synapse/rest/consent/consent_resource.py index 06e0fbde22..fc634a492d 100644 --- a/synapse/rest/consent/consent_resource.py +++ b/synapse/rest/consent/consent_resource.py @@ -84,14 +84,15 @@ class ConsentResource(DirectServeHtmlResource): # this is required by the request_handler wrapper self.clock = hs.get_clock() - self._default_consent_version = hs.config.user_consent_version - if self._default_consent_version is None: + # Consent must be configured to create this resource. + default_consent_version = hs.config.consent.user_consent_version + consent_template_directory = hs.config.consent.user_consent_template_dir + if default_consent_version is None or consent_template_directory is None: raise ConfigError( "Consent resource is enabled but user_consent section is " "missing in config file." ) - - consent_template_directory = hs.config.user_consent_template_dir + self._default_consent_version = default_consent_version # TODO: switch to synapse.util.templates.build_jinja_env loader = jinja2.FileSystemLoader(consent_template_directory) |