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

Commit

Permalink
Remove backing code for groups/communities (#12558)
Browse files Browse the repository at this point in the history
Including handlers, configuration code, appservice support, and
the GroupID construct.
  • Loading branch information
clokep committed May 26, 2022
1 parent 1cba285 commit 49f0686
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 1,894 deletions.
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

0 comments on commit 49f0686

Please sign in to comment.