mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-08 05:22:01 +00:00
Merge remote-tracking branch 'origin/develop' into HEAD
This commit is contained in:
commit
45c4e19c74
1
changelog.d/4881.misc
Normal file
1
changelog.d/4881.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Update link to federation docs.
|
1
changelog.d/4886.bugfix
Normal file
1
changelog.d/4886.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
fix test_auto_create_auto_join_where_no_consent.
|
1
changelog.d/4886.misc
Normal file
1
changelog.d/4886.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
fix test_auto_create_auto_join_where_no_consent.
|
1
changelog.d/4887.feature
Normal file
1
changelog.d/4887.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
The user directory has been rewritten to make it faster, with less chance of falling behind on a large server.
|
@ -15,8 +15,8 @@ machine's public DNS hostname, and provide Synapse with a TLS certificate
|
|||||||
which is valid for your ``server_name``.
|
which is valid for your ``server_name``.
|
||||||
|
|
||||||
Once you have completed the steps necessary to federate, you should be able to
|
Once you have completed the steps necessary to federate, you should be able to
|
||||||
join a room via federation. (A good place to start is ``#synapse:matrix.org``
|
join a room via federation. (A good place to start is ``#synapse:matrix.org`` - a
|
||||||
- a room for Synapse admins.)
|
room for Synapse admins.)
|
||||||
|
|
||||||
|
|
||||||
## Delegation
|
## Delegation
|
||||||
@ -89,7 +89,6 @@ In our example, we would need to add this SRV record in the
|
|||||||
|
|
||||||
_matrix._tcp.example.com. 3600 IN SRV 10 5 443 synapse.example.com.
|
_matrix._tcp.example.com. 3600 IN SRV 10 5 443 synapse.example.com.
|
||||||
|
|
||||||
|
|
||||||
Once done and set up, you can check the DNS record with ``dig -t srv
|
Once done and set up, you can check the DNS record with ``dig -t srv
|
||||||
_matrix._tcp.<server_name>``. In our example, we would expect this:
|
_matrix._tcp.<server_name>``. In our example, we would expect this:
|
||||||
|
|
||||||
@ -117,7 +116,6 @@ you invite them to. This can be caused by an incorrectly-configured reverse
|
|||||||
proxy: see [reverse_proxy.rst](<reverse_proxy.rst>) for instructions on how to correctly
|
proxy: see [reverse_proxy.rst](<reverse_proxy.rst>) for instructions on how to correctly
|
||||||
configure a reverse proxy.
|
configure a reverse proxy.
|
||||||
|
|
||||||
|
|
||||||
## Running a Demo Federation of Synapses
|
## Running a Demo Federation of Synapses
|
||||||
|
|
||||||
If you want to get up and running quickly with a trio of homeservers in a
|
If you want to get up and running quickly with a trio of homeservers in a
|
||||||
|
@ -18,7 +18,7 @@ servers do not necessarily need to connect to your server via the same server
|
|||||||
name or port. Indeed, clients will use port 443 by default, whereas servers
|
name or port. Indeed, clients will use port 443 by default, whereas servers
|
||||||
default to port 8448. Where these are different, we refer to the 'client port'
|
default to port 8448. Where these are different, we refer to the 'client port'
|
||||||
and the 'federation port'. See `Setting up federation
|
and the 'federation port'. See `Setting up federation
|
||||||
<../README.rst#setting-up-federation>`_ for more details of the algorithm used for
|
<federate.md>`_ for more details of the algorithm used for
|
||||||
federation connections.
|
federation connections.
|
||||||
|
|
||||||
Let's assume that we expect clients to connect to our server at
|
Let's assume that we expect clients to connect to our server at
|
||||||
|
@ -243,7 +243,14 @@ class EventCreationHandler(object):
|
|||||||
|
|
||||||
self.spam_checker = hs.get_spam_checker()
|
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)
|
self._consent_uri_builder = ConsentURIBuilder(self.config)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
@ -378,7 +385,7 @@ class EventCreationHandler(object):
|
|||||||
Raises:
|
Raises:
|
||||||
ConsentNotGivenError: if the user has not given consent yet
|
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
|
return
|
||||||
|
|
||||||
# exempt AS users from needing consent
|
# exempt AS users from needing consent
|
||||||
@ -405,7 +412,7 @@ class EventCreationHandler(object):
|
|||||||
consent_uri = self._consent_uri_builder.build_user_consent_uri(
|
consent_uri = self._consent_uri_builder.build_user_consent_uri(
|
||||||
requester.user.localpart,
|
requester.user.localpart,
|
||||||
)
|
)
|
||||||
msg = self.config.block_events_without_consent_error % {
|
msg = self._block_events_without_consent_error % {
|
||||||
'consent_uri': consent_uri,
|
'consent_uri': consent_uri,
|
||||||
}
|
}
|
||||||
raise ConsentNotGivenError(
|
raise ConsentNotGivenError(
|
||||||
|
@ -23,6 +23,7 @@ from synapse.api.constants import LoginType
|
|||||||
from synapse.api.errors import (
|
from synapse.api.errors import (
|
||||||
AuthError,
|
AuthError,
|
||||||
Codes,
|
Codes,
|
||||||
|
ConsentNotGivenError,
|
||||||
InvalidCaptchaError,
|
InvalidCaptchaError,
|
||||||
LimitExceededError,
|
LimitExceededError,
|
||||||
RegistrationError,
|
RegistrationError,
|
||||||
@ -311,6 +312,10 @@ class RegistrationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
yield self._join_user_to_room(fake_requester, r)
|
yield self._join_user_to_room(fake_requester, r)
|
||||||
|
except ConsentNotGivenError as e:
|
||||||
|
# Technically not necessary to pull out this error though
|
||||||
|
# moving away from bare excepts is a good thing to do.
|
||||||
|
logger.error("Failed to join new user to %r: %r", r, e)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to join new user to %r: %r", r, e)
|
logger.error("Failed to join new user to %r: %r", r, e)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
|
|||||||
|
|
||||||
-- Insert all users, if search_all_users is on
|
-- Insert all users, if search_all_users is on
|
||||||
INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
|
INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
|
||||||
('populate_user_directory_process_users', '{}', 'populate_user_directory_rooms');
|
('populate_user_directory_process_users', '{}', 'populate_user_directory_process_rooms');
|
||||||
|
|
||||||
-- Clean up staging tables
|
-- Clean up staging tables
|
||||||
INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
|
INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
|
||||||
|
@ -187,12 +187,32 @@ class RegistrationTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_auto_create_auto_join_where_no_consent(self):
|
def test_auto_create_auto_join_where_no_consent(self):
|
||||||
self.hs.config.user_consent_at_registration = True
|
"""Test to ensure that the first user is not auto-joined to a room if
|
||||||
self.hs.config.block_events_without_consent_error = "Error"
|
they have not given general consent.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Given:-
|
||||||
|
# * a user must give consent,
|
||||||
|
# * they have not given that consent
|
||||||
|
# * The server is configured to auto-join to a room
|
||||||
|
# (and autocreate if necessary)
|
||||||
|
|
||||||
|
event_creation_handler = self.hs.get_event_creation_handler()
|
||||||
|
# (Messing with the internals of event_creation_handler is fragile
|
||||||
|
# but can't see a better way to do this. One option could be to subclass
|
||||||
|
# the test with custom config.)
|
||||||
|
event_creation_handler._block_events_without_consent_error = ("Error")
|
||||||
|
event_creation_handler._consent_uri_builder = Mock()
|
||||||
room_alias_str = "#room:test"
|
room_alias_str = "#room:test"
|
||||||
self.hs.config.auto_join_rooms = [room_alias_str]
|
self.hs.config.auto_join_rooms = [room_alias_str]
|
||||||
|
|
||||||
|
# When:-
|
||||||
|
# * the user is registered and post consent actions are called
|
||||||
res = yield self.handler.register(localpart='jeff')
|
res = yield self.handler.register(localpart='jeff')
|
||||||
yield self.handler.post_consent_actions(res[0])
|
yield self.handler.post_consent_actions(res[0])
|
||||||
|
|
||||||
|
# Then:-
|
||||||
|
# * Ensure that they have not been joined to the room
|
||||||
rooms = yield self.store.get_rooms_for_user(res[0])
|
rooms = yield self.store.get_rooms_for_user(res[0])
|
||||||
self.assertEqual(len(rooms), 0)
|
self.assertEqual(len(rooms), 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user