From 7bc08f320147a1d80371eb13258328c88073fad0 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 1 Jun 2022 09:41:25 -0400 Subject: [PATCH] Remove remaining bits of groups code. (#12936) * Update worker docs to remove group endpoints. * Removes an unused parameter to `ApplicationService`. * Break dependency between media repo and groups. * Avoid copying `m.room.related_groups` state events during room upgrades. --- changelog.d/12936.removal | 1 + docs/workers.md | 6 ------ synapse/api/constants.py | 1 - synapse/appservice/__init__.py | 2 -- synapse/config/appservice.py | 1 - synapse/handlers/room.py | 1 - synapse/storage/databases/main/media_repository.py | 4 ---- tests/api/test_auth.py | 2 -- tests/api/test_ratelimiting.py | 2 -- tests/appservice/test_api.py | 1 - tests/appservice/test_appservice.py | 1 - tests/handlers/test_appservice.py | 3 --- tests/handlers/test_user_directory.py | 1 - tests/rest/client/test_account.py | 1 - tests/rest/client/test_login.py | 2 -- tests/rest/client/test_register.py | 2 -- tests/rest/client/test_room_batch.py | 1 - tests/storage/test_user_directory.py | 1 - tests/test_mau.py | 3 --- 19 files changed, 1 insertion(+), 35 deletions(-) create mode 100644 changelog.d/12936.removal diff --git a/changelog.d/12936.removal b/changelog.d/12936.removal new file mode 100644 index 000000000000..41f6fae5da91 --- /dev/null +++ b/changelog.d/12936.removal @@ -0,0 +1 @@ +Remove support for the non-standard groups/communities feature from Synapse. diff --git a/docs/workers.md b/docs/workers.md index 78973a498c45..6969c424d8cd 100644 --- a/docs/workers.md +++ b/docs/workers.md @@ -191,7 +191,6 @@ information. ^/_matrix/federation/v1/event_auth/ ^/_matrix/federation/v1/exchange_third_party_invite/ ^/_matrix/federation/v1/user/devices/ - ^/_matrix/federation/v1/get_groups_publicised$ ^/_matrix/key/v2/query ^/_matrix/federation/v1/hierarchy/ @@ -213,9 +212,6 @@ information. ^/_matrix/client/(r0|v3|unstable)/devices$ ^/_matrix/client/versions$ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$ - ^/_matrix/client/(r0|v3|unstable)/joined_groups$ - ^/_matrix/client/(r0|v3|unstable)/publicised_groups$ - ^/_matrix/client/(r0|v3|unstable)/publicised_groups/ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event/ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms$ ^/_matrix/client/(api/v1|r0|v3|unstable)/search$ @@ -255,9 +251,7 @@ information. Additionally, the following REST endpoints can be handled for GET requests: - ^/_matrix/federation/v1/groups/ ^/_matrix/client/(api/v1|r0|v3|unstable)/pushrules/ - ^/_matrix/client/(r0|v3|unstable)/groups/ Pagination requests can also be handled, but all requests for a given room must be routed to the same instance. Additionally, care must be taken to diff --git a/synapse/api/constants.py b/synapse/api/constants.py index f03fdd6dae78..e1d31cabed23 100644 --- a/synapse/api/constants.py +++ b/synapse/api/constants.py @@ -95,7 +95,6 @@ class EventTypes: Aliases: Final = "m.room.aliases" Redaction: Final = "m.room.redaction" ThirdPartyInvite: Final = "m.room.third_party_invite" - RelatedGroups: Final = "m.room.related_groups" RoomHistoryVisibility: Final = "m.room.history_visibility" CanonicalAlias: Final = "m.room.canonical_alias" diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py index ed92c2e91012..0dfa00df44c7 100644 --- a/synapse/appservice/__init__.py +++ b/synapse/appservice/__init__.py @@ -70,7 +70,6 @@ class ApplicationService: def __init__( self, token: str, - hostname: str, id: str, sender: str, url: Optional[str] = None, @@ -88,7 +87,6 @@ def __init__( ) # url must not end with a slash self.hs_token = hs_token self.sender = sender - self.server_name = hostname self.namespaces = self._check_namespaces(namespaces) self.id = id self.ip_range_whitelist = ip_range_whitelist diff --git a/synapse/config/appservice.py b/synapse/config/appservice.py index 24498e794433..16f93273b3d9 100644 --- a/synapse/config/appservice.py +++ b/synapse/config/appservice.py @@ -179,7 +179,6 @@ def _load_appservice( return ApplicationService( token=as_info["as_token"], - hostname=hostname, url=as_info["url"], namespaces=as_info["namespaces"], hs_token=as_info["hs_token"], diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 5c91d33f583f..e1341dd9bb3b 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -468,7 +468,6 @@ async def clone_existing_room( (EventTypes.RoomAvatar, ""), (EventTypes.RoomEncryption, ""), (EventTypes.ServerACL, ""), - (EventTypes.RelatedGroups, ""), (EventTypes.PowerLevels, ""), ] diff --git a/synapse/storage/databases/main/media_repository.py b/synapse/storage/databases/main/media_repository.py index 40ac377ca95e..deffdc19ce9f 100644 --- a/synapse/storage/databases/main/media_repository.py +++ b/synapse/storage/databases/main/media_repository.py @@ -276,10 +276,6 @@ async def get_local_media_before( (SELECT 1 FROM profiles WHERE profiles.avatar_url = '{media_prefix}' || lmr.media_id) - AND NOT EXISTS - (SELECT 1 - FROM groups - WHERE groups.avatar_url = '{media_prefix}' || lmr.media_id) AND NOT EXISTS (SELECT 1 FROM room_memberships diff --git a/tests/api/test_auth.py b/tests/api/test_auth.py index d547df8a648d..bc75ddd3e954 100644 --- a/tests/api/test_auth.py +++ b/tests/api/test_auth.py @@ -404,7 +404,6 @@ def test_blocking_mau__appservice_requester_allowed_when_not_tracking_ips(self): appservice = ApplicationService( "abcd", - self.hs.config.server.server_name, id="1234", namespaces={ "users": [{"regex": "@_appservice.*:sender", "exclusive": True}] @@ -433,7 +432,6 @@ def test_blocking_mau__appservice_requester_disallowed_when_tracking_ips(self): appservice = ApplicationService( "abcd", - self.hs.config.server.server_name, id="1234", namespaces={ "users": [{"regex": "@_appservice.*:sender", "exclusive": True}] diff --git a/tests/api/test_ratelimiting.py b/tests/api/test_ratelimiting.py index 483d5463add2..f661a9ff8e2f 100644 --- a/tests/api/test_ratelimiting.py +++ b/tests/api/test_ratelimiting.py @@ -31,7 +31,6 @@ def test_allowed_via_can_do_action(self): def test_allowed_appservice_ratelimited_via_can_requester_do_action(self): appservice = ApplicationService( None, - "example.com", id="foo", rate_limited=True, sender="@as:example.com", @@ -62,7 +61,6 @@ def test_allowed_appservice_ratelimited_via_can_requester_do_action(self): def test_allowed_appservice_via_can_requester_do_action(self): appservice = ApplicationService( None, - "example.com", id="foo", rate_limited=False, sender="@as:example.com", diff --git a/tests/appservice/test_api.py b/tests/appservice/test_api.py index 3e0db4dd9871..532b6763652b 100644 --- a/tests/appservice/test_api.py +++ b/tests/appservice/test_api.py @@ -37,7 +37,6 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer): url=URL, token="unused", hs_token=TOKEN, - hostname="myserver", ) def test_query_3pe_authenticates_token(self): diff --git a/tests/appservice/test_appservice.py b/tests/appservice/test_appservice.py index 7135362f7618..3018d3fc6f21 100644 --- a/tests/appservice/test_appservice.py +++ b/tests/appservice/test_appservice.py @@ -33,7 +33,6 @@ def setUp(self): sender="@as:test", url="some_url", token="some_token", - hostname="matrix.org", # only used by get_groups_for_user ) self.event = Mock( event_id="$abc:xyz", diff --git a/tests/handlers/test_appservice.py b/tests/handlers/test_appservice.py index 0e100c404dc8..d96d5aa1385e 100644 --- a/tests/handlers/test_appservice.py +++ b/tests/handlers/test_appservice.py @@ -697,7 +697,6 @@ def _register_application_service( # Create an application service appservice = ApplicationService( token=random_string(10), - hostname="example.com", id=random_string(10), sender="@as:example.com", rate_limited=False, @@ -776,7 +775,6 @@ def test_application_service_receives_device_list_updates( # Create an appservice that is interested in "local_user" appservice = ApplicationService( token=random_string(10), - hostname="example.com", id=random_string(10), sender="@as:example.com", rate_limited=False, @@ -843,7 +841,6 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self._service_token = "VERYSECRET" self._service = ApplicationService( self._service_token, - "as1.invalid", "as1", "@as.sender:test", namespaces={ diff --git a/tests/handlers/test_user_directory.py b/tests/handlers/test_user_directory.py index a68c2ffd4530..9e39cd97e5bf 100644 --- a/tests/handlers/test_user_directory.py +++ b/tests/handlers/test_user_directory.py @@ -60,7 +60,6 @@ def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: self.appservice = ApplicationService( token="i_am_an_app_service", - hostname="test", id="1234", namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]}, # Note: this user does not match the regex above, so that tests diff --git a/tests/rest/client/test_account.py b/tests/rest/client/test_account.py index e0a11da97b67..a43a1372733b 100644 --- a/tests/rest/client/test_account.py +++ b/tests/rest/client/test_account.py @@ -548,7 +548,6 @@ def test_GET_whoami_appservices(self) -> None: appservice = ApplicationService( as_token, - self.hs.config.server.server_name, id="1234", namespaces={"users": [{"regex": user_id, "exclusive": True}]}, sender=user_id, diff --git a/tests/rest/client/test_login.py b/tests/rest/client/test_login.py index 4920468f7ab8..f4ea1209d943 100644 --- a/tests/rest/client/test_login.py +++ b/tests/rest/client/test_login.py @@ -1112,7 +1112,6 @@ def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: self.service = ApplicationService( id="unique_identifier", token="some_token", - hostname="example.com", sender="@asbot:example.com", namespaces={ ApplicationService.NS_USERS: [ @@ -1125,7 +1124,6 @@ def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: self.another_service = ApplicationService( id="another__identifier", token="another_token", - hostname="example.com", sender="@as2bot:example.com", namespaces={ ApplicationService.NS_USERS: [ diff --git a/tests/rest/client/test_register.py b/tests/rest/client/test_register.py index 9aebf1735a96..afb08b2736de 100644 --- a/tests/rest/client/test_register.py +++ b/tests/rest/client/test_register.py @@ -56,7 +56,6 @@ def test_POST_appservice_registration_valid(self) -> None: appservice = ApplicationService( as_token, - self.hs.config.server.server_name, id="1234", namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]}, sender="@as:test", @@ -80,7 +79,6 @@ def test_POST_appservice_registration_no_type(self) -> None: appservice = ApplicationService( as_token, - self.hs.config.server.server_name, id="1234", namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]}, sender="@as:test", diff --git a/tests/rest/client/test_room_batch.py b/tests/rest/client/test_room_batch.py index 1b7ee08ab2c0..9d5cb60d1682 100644 --- a/tests/rest/client/test_room_batch.py +++ b/tests/rest/client/test_room_batch.py @@ -71,7 +71,6 @@ def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: self.appservice = ApplicationService( token="i_am_an_app_service", - hostname="test", id="1234", namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]}, # Note: this user does not have to match the regex above diff --git a/tests/storage/test_user_directory.py b/tests/storage/test_user_directory.py index 7f1964eb6a3d..5b60cf5285e4 100644 --- a/tests/storage/test_user_directory.py +++ b/tests/storage/test_user_directory.py @@ -134,7 +134,6 @@ class UserDirectoryInitialPopulationTestcase(HomeserverTestCase): def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: self.appservice = ApplicationService( token="i_am_an_app_service", - hostname="test", id="1234", namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]}, sender="@as:test", diff --git a/tests/test_mau.py b/tests/test_mau.py index 5bbc361aa240..f14fcb7db9ba 100644 --- a/tests/test_mau.py +++ b/tests/test_mau.py @@ -105,7 +105,6 @@ def test_as_ignores_mau(self): self.store.services_cache.append( ApplicationService( token=as_token, - hostname=self.hs.hostname, id="SomeASID", sender="@as_sender:test", namespaces={"users": [{"regex": "@as_*", "exclusive": True}]}, @@ -251,7 +250,6 @@ def advance_time_and_sync(): self.store.services_cache.append( ApplicationService( token=as_token_1, - hostname=self.hs.hostname, id="SomeASID", sender="@as_sender_1:test", namespaces={"users": [{"regex": "@as_1.*", "exclusive": True}]}, @@ -262,7 +260,6 @@ def advance_time_and_sync(): self.store.services_cache.append( ApplicationService( token=as_token_2, - hostname=self.hs.hostname, id="AnotherASID", sender="@as_sender_2:test", namespaces={"users": [{"regex": "@as_2.*", "exclusive": True}]},