mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Allow unhiding events that the C-S API filters away by default
This commit is contained in:
parent
0febcc4664
commit
9d230e1f59
@ -1173,7 +1173,6 @@ class SyncHandler:
|
|||||||
for e in await sync_config.filter_collection.filter_room_state(
|
for e in await sync_config.filter_collection.filter_room_state(
|
||||||
list(state.values())
|
list(state.values())
|
||||||
)
|
)
|
||||||
if e.type != EventTypes.Aliases # until MSC2261 or alternative solution
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async def _find_missing_partial_state_memberships(
|
async def _find_missing_partial_state_memberships(
|
||||||
|
@ -37,6 +37,7 @@ class StorageControllers:
|
|||||||
# rewrite all the existing code to split it into high vs low level
|
# rewrite all the existing code to split it into high vs low level
|
||||||
# interfaces.
|
# interfaces.
|
||||||
self.main = stores.main
|
self.main = stores.main
|
||||||
|
self.hs = hs
|
||||||
|
|
||||||
self.purge_events = PurgeEventsStorageController(hs, stores)
|
self.purge_events = PurgeEventsStorageController(hs, stores)
|
||||||
self.state = StateStorageController(hs, stores)
|
self.state = StateStorageController(hs, stores)
|
||||||
|
@ -116,6 +116,10 @@ async def filter_events_for_client(
|
|||||||
room_id
|
room_id
|
||||||
] = await storage.main.get_retention_policy_for_room(room_id)
|
] = await storage.main.get_retention_policy_for_room(room_id)
|
||||||
|
|
||||||
|
# meow: let admins see secret events like org.matrix.dummy_event, m.room.aliases
|
||||||
|
# and events expired by the retention policy.
|
||||||
|
filter_override = user_id in storage.hs.config.meow.filter_override
|
||||||
|
|
||||||
def allowed(event: EventBase) -> Optional[EventBase]:
|
def allowed(event: EventBase) -> Optional[EventBase]:
|
||||||
return _check_client_allowed_to_see_event(
|
return _check_client_allowed_to_see_event(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
@ -128,6 +132,7 @@ async def filter_events_for_client(
|
|||||||
state=event_id_to_state.get(event.event_id),
|
state=event_id_to_state.get(event.event_id),
|
||||||
is_peeking=is_peeking,
|
is_peeking=is_peeking,
|
||||||
sender_erased=erased_senders.get(event.sender, False),
|
sender_erased=erased_senders.get(event.sender, False),
|
||||||
|
filter_override=filter_override,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check each event: gives an iterable of None or (a potentially modified)
|
# Check each event: gives an iterable of None or (a potentially modified)
|
||||||
@ -275,6 +280,7 @@ def _check_client_allowed_to_see_event(
|
|||||||
retention_policy: RetentionPolicy,
|
retention_policy: RetentionPolicy,
|
||||||
state: Optional[StateMap[EventBase]],
|
state: Optional[StateMap[EventBase]],
|
||||||
sender_erased: bool,
|
sender_erased: bool,
|
||||||
|
filter_override: bool,
|
||||||
) -> Optional[EventBase]:
|
) -> Optional[EventBase]:
|
||||||
"""Check with the given user is allowed to see the given event
|
"""Check with the given user is allowed to see the given event
|
||||||
|
|
||||||
@ -291,6 +297,7 @@ def _check_client_allowed_to_see_event(
|
|||||||
retention_policy: The retention policy of the room
|
retention_policy: The retention policy of the room
|
||||||
state: The state at the event, unless its an outlier
|
state: The state at the event, unless its an outlier
|
||||||
sender_erased: Whether the event sender has been marked as "erased"
|
sender_erased: Whether the event sender has been marked as "erased"
|
||||||
|
filter_override: meow
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None if the user cannot see this event at all
|
None if the user cannot see this event at all
|
||||||
@ -304,7 +311,7 @@ def _check_client_allowed_to_see_event(
|
|||||||
# because, if this is not the case, we're probably only checking if the users can
|
# because, if this is not the case, we're probably only checking if the users can
|
||||||
# see events in the room at that point in the DAG, and that shouldn't be decided
|
# see events in the room at that point in the DAG, and that shouldn't be decided
|
||||||
# on those checks.
|
# on those checks.
|
||||||
if filter_send_to_client:
|
if filter_send_to_client and not filter_override:
|
||||||
if (
|
if (
|
||||||
_check_filter_send_to_client(event, clock, retention_policy, sender_ignored)
|
_check_filter_send_to_client(event, clock, retention_policy, sender_ignored)
|
||||||
== _CheckFilter.DENIED
|
== _CheckFilter.DENIED
|
||||||
@ -314,6 +321,9 @@ def _check_client_allowed_to_see_event(
|
|||||||
event.event_id,
|
event.event_id,
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
# meow: even with filter_override, we want to filter ignored users
|
||||||
|
elif filter_send_to_client and not event.is_state() and sender_ignored:
|
||||||
|
return None
|
||||||
|
|
||||||
if event.event_id in always_include_ids:
|
if event.event_id in always_include_ids:
|
||||||
return event
|
return event
|
||||||
|
Loading…
Reference in New Issue
Block a user