Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 49f0686

Browse files
authored
Remove backing code for groups/communities (#12558)
Including handlers, configuration code, appservice support, and the GroupID construct.
1 parent 1cba285 commit 49f0686

File tree

13 files changed

+6
-1894
lines changed

13 files changed

+6
-1894
lines changed

changelog.d/12558.removal

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove support for the non-standard groups/communities feature from Synapse.

synapse/appservice/__init__.py

+2-41
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@
2323

2424
from synapse.api.constants import EventTypes
2525
from synapse.events import EventBase
26-
from synapse.types import (
27-
DeviceListUpdates,
28-
GroupID,
29-
JsonDict,
30-
UserID,
31-
get_domain_from_id,
32-
)
26+
from synapse.types import DeviceListUpdates, JsonDict, UserID
3327
from synapse.util.caches.descriptors import _CacheContext, cached
3428

3529
if TYPE_CHECKING:
@@ -55,7 +49,6 @@ class ApplicationServiceState(Enum):
5549
@attr.s(slots=True, frozen=True, auto_attribs=True)
5650
class Namespace:
5751
exclusive: bool
58-
group_id: Optional[str]
5952
regex: Pattern[str]
6053

6154

@@ -141,30 +134,13 @@ def _check_namespaces(
141134
exclusive = regex_obj.get("exclusive")
142135
if not isinstance(exclusive, bool):
143136
raise ValueError("Expected bool for 'exclusive' in ns '%s'" % ns)
144-
group_id = regex_obj.get("group_id")
145-
if group_id:
146-
if not isinstance(group_id, str):
147-
raise ValueError(
148-
"Expected string for 'group_id' in ns '%s'" % ns
149-
)
150-
try:
151-
GroupID.from_string(group_id)
152-
except Exception:
153-
raise ValueError(
154-
"Expected valid group ID for 'group_id' in ns '%s'" % ns
155-
)
156-
157-
if get_domain_from_id(group_id) != self.server_name:
158-
raise ValueError(
159-
"Expected 'group_id' to be this host in ns '%s'" % ns
160-
)
161137

162138
regex = regex_obj.get("regex")
163139
if not isinstance(regex, str):
164140
raise ValueError("Expected string for 'regex' in ns '%s'" % ns)
165141

166142
# Pre-compile regex.
167-
result[ns].append(Namespace(exclusive, group_id, re.compile(regex)))
143+
result[ns].append(Namespace(exclusive, re.compile(regex)))
168144

169145
return result
170146

@@ -369,21 +345,6 @@ def get_exclusive_user_regexes(self) -> List[Pattern[str]]:
369345
if namespace.exclusive
370346
]
371347

372-
def get_groups_for_user(self, user_id: str) -> Iterable[str]:
373-
"""Get the groups that this user is associated with by this AS
374-
375-
Args:
376-
user_id: The ID of the user.
377-
378-
Returns:
379-
An iterable that yields group_id strings.
380-
"""
381-
return (
382-
namespace.group_id
383-
for namespace in self.namespaces[ApplicationService.NS_USERS]
384-
if namespace.group_id and namespace.regex.match(user_id)
385-
)
386-
387348
def is_rate_limited(self) -> bool:
388349
return self.rate_limited
389350

synapse/config/_base.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ from synapse.config import (
3232
emailconfig,
3333
experimental,
3434
federation,
35-
groups,
3635
jwt,
3736
key,
3837
logger,
@@ -107,7 +106,6 @@ class RootConfig:
107106
push: push.PushConfig
108107
spamchecker: spam_checker.SpamCheckerConfig
109108
room: room.RoomConfig
110-
groups: groups.GroupsConfig
111109
userdirectory: user_directory.UserDirectoryConfig
112110
consent: consent.ConsentConfig
113111
stats: stats.StatsConfig

synapse/config/groups.py

-27
This file was deleted.

synapse/config/homeserver.py

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from .emailconfig import EmailConfig
2626
from .experimental import ExperimentalConfig
2727
from .federation import FederationConfig
28-
from .groups import GroupsConfig
2928
from .jwt import JWTConfig
3029
from .key import KeyConfig
3130
from .logger import LoggingConfig
@@ -89,7 +88,6 @@ class HomeServerConfig(RootConfig):
8988
PushConfig,
9089
SpamCheckerConfig,
9190
RoomConfig,
92-
GroupsConfig,
9391
UserDirectoryConfig,
9492
ConsentConfig,
9593
StatsConfig,

synapse/groups/__init__.py

Whitespace-only changes.

synapse/groups/attestations.py

-218
This file was deleted.

0 commit comments

Comments
 (0)