Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,14 @@ def __init__(self, hs):

self.spam_checker = hs.get_spam_checker()

if self.config.block_events_without_consent_error is not None:
self._block_events_without_consent_error = (
self.config.block_events_without_consent_error
)

# we need to construct a ConsentURIBuilder here, as it checks that the necessary
# config options, but *only* if we have a configuration for which we are
# going to need it.
if self._block_events_without_consent_error:
self._consent_uri_builder = ConsentURIBuilder(self.config)

@defer.inlineCallbacks
Expand Down Expand Up @@ -378,7 +385,7 @@ def assert_accepted_privacy_policy(self, requester):
Raises:
ConsentNotGivenError: if the user has not given consent yet
"""
if self.config.block_events_without_consent_error is None:
if self._block_events_without_consent_error is None:
return

# exempt AS users from needing consent
Expand All @@ -405,7 +412,7 @@ def assert_accepted_privacy_policy(self, requester):
consent_uri = self._consent_uri_builder.build_user_consent_uri(
requester.user.localpart,
)
msg = self.config.block_events_without_consent_error % {
msg = self._block_events_without_consent_error % {
'consent_uri': consent_uri,
}
raise ConsentNotGivenError(
Expand Down
6 changes: 6 additions & 0 deletions tests/handlers/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ def test_auto_create_auto_join_rooms_when_support_user_exists(self):

@defer.inlineCallbacks
def test_auto_create_auto_join_where_no_consent(self):
"""XXX what is this trying to test? I *think* it is trying to test
that we are not auto-joined to the server notices room if
block_events_without_consent_error is set, but (a) that doesn't seem to be
a sensible thing to test for, and (b) it doesn't work anyway because you can't
change the config after the EventCreationHandler has been instantiated.
"""
self.hs.config.user_consent_at_registration = True
self.hs.config.block_events_without_consent_error = "Error"
room_alias_str = "#room:test"
Expand Down