FIXUP: Don't filter events at all for admin/v1/rooms/.../context/...
parent
fe52dae6bd
commit
de7f049527
|
@ -52,7 +52,7 @@ from synapse.types import (
|
||||||
create_requester,
|
create_requester,
|
||||||
)
|
)
|
||||||
from synapse.util import stringutils
|
from synapse.util import stringutils
|
||||||
from synapse.util.async_helpers import Linearizer
|
from synapse.util.async_helpers import Linearizer, maybe_awaitable
|
||||||
from synapse.util.caches.response_cache import ResponseCache
|
from synapse.util.caches.response_cache import ResponseCache
|
||||||
from synapse.util.stringutils import parse_and_validate_server_name
|
from synapse.util.stringutils import parse_and_validate_server_name
|
||||||
from synapse.visibility import filter_events_for_client
|
from synapse.visibility import filter_events_for_client
|
||||||
|
@ -1034,12 +1034,10 @@ class RoomContextHandler:
|
||||||
is_peeking = user.to_string() not in users
|
is_peeking = user.to_string() not in users
|
||||||
|
|
||||||
def filter_evts(events):
|
def filter_evts(events):
|
||||||
|
if use_admin_priviledge:
|
||||||
|
return maybe_awaitable(events)
|
||||||
return filter_events_for_client(
|
return filter_events_for_client(
|
||||||
self.storage,
|
self.storage, user.to_string(), events, is_peeking=is_peeking
|
||||||
user.to_string(),
|
|
||||||
events,
|
|
||||||
is_peeking=is_peeking,
|
|
||||||
use_admin_priviledge=use_admin_priviledge,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
event = await self.store.get_event(
|
event = await self.store.get_event(
|
||||||
|
|
|
@ -53,7 +53,6 @@ async def filter_events_for_client(
|
||||||
is_peeking=False,
|
is_peeking=False,
|
||||||
always_include_ids=frozenset(),
|
always_include_ids=frozenset(),
|
||||||
filter_send_to_client=True,
|
filter_send_to_client=True,
|
||||||
use_admin_priviledge=False,
|
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Check which events a user is allowed to see. If the user can see the event but its
|
Check which events a user is allowed to see. If the user can see the event but its
|
||||||
|
@ -72,9 +71,6 @@ async def filter_events_for_client(
|
||||||
filter_send_to_client (bool): Whether we're checking an event that's going to be
|
filter_send_to_client (bool): Whether we're checking an event that's going to be
|
||||||
sent to a client. This might not always be the case since this function can
|
sent to a client. This might not always be the case since this function can
|
||||||
also be called to check whether a user can see the state at a given point.
|
also be called to check whether a user can see the state at a given point.
|
||||||
use_admin_priviledge: if `True`, return all events, regardless
|
|
||||||
of whether `user` has access to them. To be used **ONLY**
|
|
||||||
from the admin API.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[synapse.events.EventBase]
|
list[synapse.events.EventBase]
|
||||||
|
@ -83,23 +79,16 @@ async def filter_events_for_client(
|
||||||
# to clients.
|
# to clients.
|
||||||
events = [e for e in events if not e.internal_metadata.is_soft_failed()]
|
events = [e for e in events if not e.internal_metadata.is_soft_failed()]
|
||||||
|
|
||||||
types = None
|
types = ((EventTypes.RoomHistoryVisibility, ""), (EventTypes.Member, user_id))
|
||||||
if use_admin_priviledge:
|
|
||||||
# Administrators can access all events.
|
|
||||||
types = ((EventTypes.RoomHistoryVisibility, ""), (EventTypes.Member, None))
|
|
||||||
else:
|
|
||||||
types = ((EventTypes.RoomHistoryVisibility, ""), (EventTypes.Member, user_id))
|
|
||||||
|
|
||||||
event_id_to_state = await storage.state.get_state_for_events(
|
event_id_to_state = await storage.state.get_state_for_events(
|
||||||
frozenset(e.event_id for e in events),
|
frozenset(e.event_id for e in events),
|
||||||
state_filter=StateFilter.from_types(types),
|
state_filter=StateFilter.from_types(types),
|
||||||
)
|
)
|
||||||
|
|
||||||
ignore_dict_content = None
|
ignore_dict_content = await storage.main.get_global_account_data_by_type_for_user(
|
||||||
if not use_admin_priviledge:
|
AccountDataTypes.IGNORED_USER_LIST, user_id
|
||||||
ignore_dict_content = await storage.main.get_global_account_data_by_type_for_user(
|
)
|
||||||
AccountDataTypes.IGNORED_USER_LIST, user_id
|
|
||||||
)
|
|
||||||
|
|
||||||
ignore_list = frozenset()
|
ignore_list = frozenset()
|
||||||
if ignore_dict_content:
|
if ignore_dict_content:
|
||||||
|
@ -195,12 +184,10 @@ async def filter_events_for_client(
|
||||||
if old_priority < new_priority:
|
if old_priority < new_priority:
|
||||||
visibility = prev_visibility
|
visibility = prev_visibility
|
||||||
|
|
||||||
membership = None
|
|
||||||
if use_admin_priviledge:
|
|
||||||
membership = Membership.JOIN
|
|
||||||
# likewise, if the event is the user's own membership event, use
|
# likewise, if the event is the user's own membership event, use
|
||||||
# the 'most joined' membership
|
# the 'most joined' membership
|
||||||
elif event.type == EventTypes.Member and event.state_key == user_id:
|
membership = None
|
||||||
|
if event.type == EventTypes.Member and event.state_key == user_id:
|
||||||
membership = event.content.get("membership", None)
|
membership = event.content.get("membership", None)
|
||||||
if membership not in MEMBERSHIP_PRIORITY:
|
if membership not in MEMBERSHIP_PRIORITY:
|
||||||
membership = "leave"
|
membership = "leave"
|
||||||
|
|
Loading…
Reference in New Issue