mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-07-26 15:55:22 -04:00
Implement MSC3827: Filtering of /publicRooms
by room type (#13031)
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
e714b8a057
commit
13e359aec8
11 changed files with 345 additions and 13 deletions
|
@ -16,7 +16,7 @@
|
|||
import logging
|
||||
from enum import Enum
|
||||
from itertools import chain
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, cast
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast
|
||||
|
||||
from typing_extensions import Counter
|
||||
|
||||
|
@ -238,6 +238,7 @@ class StatsStore(StateDeltasStore):
|
|||
* avatar
|
||||
* canonical_alias
|
||||
* guest_access
|
||||
* room_type
|
||||
|
||||
A is_federatable key can also be included with a boolean value.
|
||||
|
||||
|
@ -263,6 +264,7 @@ class StatsStore(StateDeltasStore):
|
|||
"avatar",
|
||||
"canonical_alias",
|
||||
"guest_access",
|
||||
"room_type",
|
||||
):
|
||||
field = fields.get(col, sentinel)
|
||||
if field is not sentinel and (not isinstance(field, str) or "\0" in field):
|
||||
|
@ -572,7 +574,7 @@ class StatsStore(StateDeltasStore):
|
|||
|
||||
state_event_map = await self.get_events(event_ids, get_prev_content=False) # type: ignore[attr-defined]
|
||||
|
||||
room_state = {
|
||||
room_state: Dict[str, Union[None, bool, str]] = {
|
||||
"join_rules": None,
|
||||
"history_visibility": None,
|
||||
"encryption": None,
|
||||
|
@ -581,6 +583,7 @@ class StatsStore(StateDeltasStore):
|
|||
"avatar": None,
|
||||
"canonical_alias": None,
|
||||
"is_federatable": True,
|
||||
"room_type": None,
|
||||
}
|
||||
|
||||
for event in state_event_map.values():
|
||||
|
@ -604,6 +607,9 @@ class StatsStore(StateDeltasStore):
|
|||
room_state["is_federatable"] = (
|
||||
event.content.get(EventContentFields.FEDERATE, True) is True
|
||||
)
|
||||
room_type = event.content.get(EventContentFields.ROOM_TYPE)
|
||||
if isinstance(room_type, str):
|
||||
room_state["room_type"] = room_type
|
||||
|
||||
await self.update_room_state(room_id, room_state)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue