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

Remove backing code for groups/communities #12558

Merged
merged 5 commits into from
May 26, 2022
Merged
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
1 change: 1 addition & 0 deletions changelog.d/12558.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove support for the non-standard groups/communities feature from Synapse.
43 changes: 2 additions & 41 deletions synapse/appservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@

from synapse.api.constants import EventTypes
from synapse.events import EventBase
from synapse.types import (
DeviceListUpdates,
GroupID,
JsonDict,
UserID,
get_domain_from_id,
)
from synapse.types import DeviceListUpdates, JsonDict, UserID
from synapse.util.caches.descriptors import _CacheContext, cached

if TYPE_CHECKING:
Expand All @@ -55,7 +49,6 @@ class ApplicationServiceState(Enum):
@attr.s(slots=True, frozen=True, auto_attribs=True)
class Namespace:
exclusive: bool
group_id: Optional[str]
regex: Pattern[str]


Expand Down Expand Up @@ -141,30 +134,13 @@ def _check_namespaces(
exclusive = regex_obj.get("exclusive")
if not isinstance(exclusive, bool):
raise ValueError("Expected bool for 'exclusive' in ns '%s'" % ns)
group_id = regex_obj.get("group_id")
if group_id:
if not isinstance(group_id, str):
raise ValueError(
"Expected string for 'group_id' in ns '%s'" % ns
)
try:
GroupID.from_string(group_id)
except Exception:
raise ValueError(
"Expected valid group ID for 'group_id' in ns '%s'" % ns
)

if get_domain_from_id(group_id) != self.server_name:
raise ValueError(
"Expected 'group_id' to be this host in ns '%s'" % ns
)

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

# Pre-compile regex.
result[ns].append(Namespace(exclusive, group_id, re.compile(regex)))
result[ns].append(Namespace(exclusive, re.compile(regex)))

return result

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

def get_groups_for_user(self, user_id: str) -> Iterable[str]:
"""Get the groups that this user is associated with by this AS

Args:
user_id: The ID of the user.

Returns:
An iterable that yields group_id strings.
"""
return (
namespace.group_id
for namespace in self.namespaces[ApplicationService.NS_USERS]
if namespace.group_id and namespace.regex.match(user_id)
)

def is_rate_limited(self) -> bool:
return self.rate_limited

Expand Down
2 changes: 0 additions & 2 deletions synapse/config/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ from synapse.config import (
emailconfig,
experimental,
federation,
groups,
jwt,
key,
logger,
Expand Down Expand Up @@ -107,7 +106,6 @@ class RootConfig:
push: push.PushConfig
spamchecker: spam_checker.SpamCheckerConfig
room: room.RoomConfig
groups: groups.GroupsConfig
userdirectory: user_directory.UserDirectoryConfig
consent: consent.ConsentConfig
stats: stats.StatsConfig
Expand Down
27 changes: 0 additions & 27 deletions synapse/config/groups.py

This file was deleted.

2 changes: 0 additions & 2 deletions synapse/config/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from .emailconfig import EmailConfig
from .experimental import ExperimentalConfig
from .federation import FederationConfig
from .groups import GroupsConfig
from .jwt import JWTConfig
from .key import KeyConfig
from .logger import LoggingConfig
Expand Down Expand Up @@ -89,7 +88,6 @@ class HomeServerConfig(RootConfig):
PushConfig,
SpamCheckerConfig,
RoomConfig,
GroupsConfig,
UserDirectoryConfig,
ConsentConfig,
StatsConfig,
Expand Down
Empty file removed synapse/groups/__init__.py
Empty file.
218 changes: 0 additions & 218 deletions synapse/groups/attestations.py

This file was deleted.

Loading