mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-17 01:34:20 -05:00
Fix up state_store
naming (#12871)
This commit is contained in:
parent
a8db8c6eba
commit
4660d9fdcf
1
changelog.d/12871.misc
Normal file
1
changelog.d/12871.misc
Normal file
@ -0,0 +1 @@
|
||||
Fix up the variable `state_store` naming.
|
@ -31,7 +31,7 @@ class AdminHandler:
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
self.store = hs.get_datastores().main
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
|
||||
async def get_whois(self, user: UserID) -> JsonDict:
|
||||
connections = []
|
||||
@ -233,7 +233,7 @@ class AdminHandler:
|
||||
for event_id in extremities:
|
||||
if not event_to_unseen_prevs[event_id]:
|
||||
continue
|
||||
state = await self.state_store.get_state_for_event(event_id)
|
||||
state = await self.state_storage.get_state_for_event(event_id)
|
||||
writer.write_state(room_id, event_id, state)
|
||||
|
||||
return writer.finished()
|
||||
|
@ -70,7 +70,7 @@ class DeviceWorkerHandler:
|
||||
self.store = hs.get_datastores().main
|
||||
self.notifier = hs.get_notifier()
|
||||
self.state = hs.get_state_handler()
|
||||
self.state_store = hs.get_storage().state
|
||||
self.state_storage = hs.get_storage().state
|
||||
self._auth_handler = hs.get_auth_handler()
|
||||
self.server_name = hs.hostname
|
||||
|
||||
@ -203,7 +203,9 @@ class DeviceWorkerHandler:
|
||||
continue
|
||||
|
||||
# mapping from event_id -> state_dict
|
||||
prev_state_ids = await self.state_store.get_state_ids_for_events(event_ids)
|
||||
prev_state_ids = await self.state_storage.get_state_ids_for_events(
|
||||
event_ids
|
||||
)
|
||||
|
||||
# Check if we've joined the room? If so we just blindly add all the users to
|
||||
# the "possibly changed" users.
|
||||
|
@ -126,7 +126,7 @@ class FederationHandler:
|
||||
|
||||
self.store = hs.get_datastores().main
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
self.federation_client = hs.get_federation_client()
|
||||
self.state_handler = hs.get_state_handler()
|
||||
self.server_name = hs.hostname
|
||||
@ -1027,7 +1027,9 @@ class FederationHandler:
|
||||
if event.internal_metadata.outlier:
|
||||
raise NotFoundError("State not known at event %s" % (event_id,))
|
||||
|
||||
state_groups = await self.state_store.get_state_groups_ids(room_id, [event_id])
|
||||
state_groups = await self.state_storage.get_state_groups_ids(
|
||||
room_id, [event_id]
|
||||
)
|
||||
|
||||
# get_state_groups_ids should return exactly one result
|
||||
assert len(state_groups) == 1
|
||||
|
@ -99,7 +99,7 @@ class FederationEventHandler:
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
self._store = hs.get_datastores().main
|
||||
self._storage = hs.get_storage()
|
||||
self._state_store = self._storage.state
|
||||
self._state_storage = self._storage.state
|
||||
|
||||
self._state_handler = hs.get_state_handler()
|
||||
self._event_creation_handler = hs.get_event_creation_handler()
|
||||
@ -533,7 +533,7 @@ class FederationEventHandler:
|
||||
)
|
||||
return
|
||||
await self._store.update_state_for_partial_state_event(event, context)
|
||||
self._state_store.notify_event_un_partial_stated(event.event_id)
|
||||
self._state_storage.notify_event_un_partial_stated(event.event_id)
|
||||
|
||||
async def backfill(
|
||||
self, dest: str, room_id: str, limit: int, extremities: Collection[str]
|
||||
@ -832,7 +832,7 @@ class FederationEventHandler:
|
||||
event_map = {event_id: event}
|
||||
try:
|
||||
# Get the state of the events we know about
|
||||
ours = await self._state_store.get_state_groups_ids(room_id, seen)
|
||||
ours = await self._state_storage.get_state_groups_ids(room_id, seen)
|
||||
|
||||
# state_maps is a list of mappings from (type, state_key) to event_id
|
||||
state_maps: List[StateMap[str]] = list(ours.values())
|
||||
@ -1626,7 +1626,7 @@ class FederationEventHandler:
|
||||
# given state at the event. This should correctly handle cases
|
||||
# like bans, especially with state res v2.
|
||||
|
||||
state_sets_d = await self._state_store.get_state_groups(
|
||||
state_sets_d = await self._state_storage.get_state_groups(
|
||||
event.room_id, extrem_ids
|
||||
)
|
||||
state_sets: List[Iterable[EventBase]] = list(state_sets_d.values())
|
||||
@ -1895,7 +1895,7 @@ class FederationEventHandler:
|
||||
|
||||
# create a new state group as a delta from the existing one.
|
||||
prev_group = context.state_group
|
||||
state_group = await self._state_store.store_state_group(
|
||||
state_group = await self._state_storage.store_state_group(
|
||||
event.event_id,
|
||||
event.room_id,
|
||||
prev_group=prev_group,
|
||||
|
@ -68,7 +68,7 @@ class InitialSyncHandler:
|
||||
] = ResponseCache(hs.get_clock(), "initial_sync_cache")
|
||||
self._event_serializer = hs.get_event_client_serializer()
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
|
||||
async def snapshot_all_rooms(
|
||||
self,
|
||||
@ -198,7 +198,7 @@ class InitialSyncHandler:
|
||||
event.stream_ordering,
|
||||
)
|
||||
deferred_room_state = run_in_background(
|
||||
self.state_store.get_state_for_events, [event.event_id]
|
||||
self.state_storage.get_state_for_events, [event.event_id]
|
||||
).addCallback(
|
||||
lambda states: cast(StateMap[EventBase], states[event.event_id])
|
||||
)
|
||||
@ -355,7 +355,7 @@ class InitialSyncHandler:
|
||||
member_event_id: str,
|
||||
is_peeking: bool,
|
||||
) -> JsonDict:
|
||||
room_state = await self.state_store.get_state_for_event(member_event_id)
|
||||
room_state = await self.state_storage.get_state_for_event(member_event_id)
|
||||
|
||||
limit = pagin_config.limit if pagin_config else None
|
||||
if limit is None:
|
||||
|
@ -78,7 +78,7 @@ class MessageHandler:
|
||||
self.state = hs.get_state_handler()
|
||||
self.store = hs.get_datastores().main
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
self._event_serializer = hs.get_event_client_serializer()
|
||||
self._ephemeral_events_enabled = hs.config.server.enable_ephemeral_messages
|
||||
|
||||
@ -125,7 +125,7 @@ class MessageHandler:
|
||||
assert (
|
||||
membership_event_id is not None
|
||||
), "check_user_in_room_or_world_readable returned invalid data"
|
||||
room_state = await self.state_store.get_state_for_events(
|
||||
room_state = await self.state_storage.get_state_for_events(
|
||||
[membership_event_id], StateFilter.from_types([key])
|
||||
)
|
||||
data = room_state[membership_event_id].get(key)
|
||||
@ -186,7 +186,7 @@ class MessageHandler:
|
||||
|
||||
# check whether the user is in the room at that time to determine
|
||||
# whether they should be treated as peeking.
|
||||
state_map = await self.state_store.get_state_for_event(
|
||||
state_map = await self.state_storage.get_state_for_event(
|
||||
last_event.event_id,
|
||||
StateFilter.from_types([(EventTypes.Member, user_id)]),
|
||||
)
|
||||
@ -207,7 +207,7 @@ class MessageHandler:
|
||||
)
|
||||
|
||||
if visible_events:
|
||||
room_state_events = await self.state_store.get_state_for_events(
|
||||
room_state_events = await self.state_storage.get_state_for_events(
|
||||
[last_event.event_id], state_filter=state_filter
|
||||
)
|
||||
room_state: Mapping[Any, EventBase] = room_state_events[
|
||||
@ -237,7 +237,7 @@ class MessageHandler:
|
||||
assert (
|
||||
membership_event_id is not None
|
||||
), "check_user_in_room_or_world_readable returned invalid data"
|
||||
room_state_events = await self.state_store.get_state_for_events(
|
||||
room_state_events = await self.state_storage.get_state_for_events(
|
||||
[membership_event_id], state_filter=state_filter
|
||||
)
|
||||
room_state = room_state_events[membership_event_id]
|
||||
|
@ -130,7 +130,7 @@ class PaginationHandler:
|
||||
self.auth = hs.get_auth()
|
||||
self.store = hs.get_datastores().main
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
self.clock = hs.get_clock()
|
||||
self._server_name = hs.hostname
|
||||
self._room_shutdown_handler = hs.get_room_shutdown_handler()
|
||||
@ -539,7 +539,7 @@ class PaginationHandler:
|
||||
(EventTypes.Member, event.sender) for event in events
|
||||
)
|
||||
|
||||
state_ids = await self.state_store.get_state_ids_for_event(
|
||||
state_ids = await self.state_storage.get_state_ids_for_event(
|
||||
events[0].event_id, state_filter=state_filter
|
||||
)
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ class RoomContextHandler:
|
||||
self.auth = hs.get_auth()
|
||||
self.store = hs.get_datastores().main
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
self._relations_handler = hs.get_relations_handler()
|
||||
|
||||
async def get_event_context(
|
||||
@ -1293,7 +1293,7 @@ class RoomContextHandler:
|
||||
# first? Shouldn't we be consistent with /sync?
|
||||
# https://github.com/matrix-org/matrix-doc/issues/687
|
||||
|
||||
state = await self.state_store.get_state_for_events(
|
||||
state = await self.state_storage.get_state_for_events(
|
||||
[last_event_id], state_filter=state_filter
|
||||
)
|
||||
|
||||
|
@ -17,7 +17,7 @@ class RoomBatchHandler:
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
self.hs = hs
|
||||
self.store = hs.get_datastores().main
|
||||
self.state_store = hs.get_storage().state
|
||||
self.state_storage = hs.get_storage().state
|
||||
self.event_creation_handler = hs.get_event_creation_handler()
|
||||
self.room_member_handler = hs.get_room_member_handler()
|
||||
self.auth = hs.get_auth()
|
||||
@ -141,7 +141,7 @@ class RoomBatchHandler:
|
||||
) = await self.store.get_max_depth_of(event_ids)
|
||||
# mapping from (type, state_key) -> state_event_id
|
||||
assert most_recent_event_id is not None
|
||||
prev_state_map = await self.state_store.get_state_ids_for_event(
|
||||
prev_state_map = await self.state_storage.get_state_ids_for_event(
|
||||
most_recent_event_id
|
||||
)
|
||||
# List of state event ID's
|
||||
|
@ -56,7 +56,7 @@ class SearchHandler:
|
||||
self._event_serializer = hs.get_event_client_serializer()
|
||||
self._relations_handler = hs.get_relations_handler()
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
self.auth = hs.get_auth()
|
||||
|
||||
async def get_old_rooms_from_upgraded_room(self, room_id: str) -> Iterable[str]:
|
||||
@ -677,7 +677,7 @@ class SearchHandler:
|
||||
[(EventTypes.Member, sender) for sender in senders]
|
||||
)
|
||||
|
||||
state = await self.state_store.get_state_for_event(
|
||||
state = await self.state_storage.get_state_for_event(
|
||||
last_event_id, state_filter
|
||||
)
|
||||
|
||||
|
@ -239,7 +239,7 @@ class SyncHandler:
|
||||
self.state = hs.get_state_handler()
|
||||
self.auth = hs.get_auth()
|
||||
self.storage = hs.get_storage()
|
||||
self.state_store = self.storage.state
|
||||
self.state_storage = self.storage.state
|
||||
|
||||
# TODO: flush cache entries on subsequent sync request.
|
||||
# Once we get the next /sync request (ie, one with the same access token
|
||||
@ -630,7 +630,7 @@ class SyncHandler:
|
||||
event: event of interest
|
||||
state_filter: The state filter used to fetch state from the database.
|
||||
"""
|
||||
state_ids = await self.state_store.get_state_ids_for_event(
|
||||
state_ids = await self.state_storage.get_state_ids_for_event(
|
||||
event.event_id, state_filter=state_filter or StateFilter.all()
|
||||
)
|
||||
if event.is_state():
|
||||
@ -710,7 +710,7 @@ class SyncHandler:
|
||||
return None
|
||||
|
||||
last_event = last_events[-1]
|
||||
state_ids = await self.state_store.get_state_ids_for_event(
|
||||
state_ids = await self.state_storage.get_state_ids_for_event(
|
||||
last_event.event_id,
|
||||
state_filter=StateFilter.from_types(
|
||||
[(EventTypes.Name, ""), (EventTypes.CanonicalAlias, "")]
|
||||
@ -888,11 +888,13 @@ class SyncHandler:
|
||||
|
||||
if full_state:
|
||||
if batch:
|
||||
current_state_ids = await self.state_store.get_state_ids_for_event(
|
||||
batch.events[-1].event_id, state_filter=state_filter
|
||||
current_state_ids = (
|
||||
await self.state_storage.get_state_ids_for_event(
|
||||
batch.events[-1].event_id, state_filter=state_filter
|
||||
)
|
||||
)
|
||||
|
||||
state_ids = await self.state_store.get_state_ids_for_event(
|
||||
state_ids = await self.state_storage.get_state_ids_for_event(
|
||||
batch.events[0].event_id, state_filter=state_filter
|
||||
)
|
||||
|
||||
@ -913,7 +915,7 @@ class SyncHandler:
|
||||
elif batch.limited:
|
||||
if batch:
|
||||
state_at_timeline_start = (
|
||||
await self.state_store.get_state_ids_for_event(
|
||||
await self.state_storage.get_state_ids_for_event(
|
||||
batch.events[0].event_id, state_filter=state_filter
|
||||
)
|
||||
)
|
||||
@ -947,8 +949,10 @@ class SyncHandler:
|
||||
)
|
||||
|
||||
if batch:
|
||||
current_state_ids = await self.state_store.get_state_ids_for_event(
|
||||
batch.events[-1].event_id, state_filter=state_filter
|
||||
current_state_ids = (
|
||||
await self.state_storage.get_state_ids_for_event(
|
||||
batch.events[-1].event_id, state_filter=state_filter
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Its not clear how we get here, but empirically we do
|
||||
@ -978,7 +982,7 @@ class SyncHandler:
|
||||
# So we fish out all the member events corresponding to the
|
||||
# timeline here, and then dedupe any redundant ones below.
|
||||
|
||||
state_ids = await self.state_store.get_state_ids_for_event(
|
||||
state_ids = await self.state_storage.get_state_ids_for_event(
|
||||
batch.events[0].event_id,
|
||||
# we only want members!
|
||||
state_filter=StateFilter.from_types(
|
||||
|
@ -114,7 +114,7 @@ class Mailer:
|
||||
|
||||
self.send_email_handler = hs.get_send_email_handler()
|
||||
self.store = self.hs.get_datastores().main
|
||||
self.state_store = self.hs.get_storage().state
|
||||
self.state_storage = self.hs.get_storage().state
|
||||
self.macaroon_gen = self.hs.get_macaroon_generator()
|
||||
self.state_handler = self.hs.get_state_handler()
|
||||
self.storage = hs.get_storage()
|
||||
@ -494,7 +494,7 @@ class Mailer:
|
||||
)
|
||||
else:
|
||||
# Attempt to check the historical state for the room.
|
||||
historical_state = await self.state_store.get_state_for_event(
|
||||
historical_state = await self.state_storage.get_state_for_event(
|
||||
event.event_id, StateFilter.from_types((type_state_key,))
|
||||
)
|
||||
sender_state_event = historical_state.get(type_state_key)
|
||||
@ -767,7 +767,7 @@ class Mailer:
|
||||
member_event_ids.append(sender_state_event_id)
|
||||
else:
|
||||
# Attempt to check the historical state for the room.
|
||||
historical_state = await self.state_store.get_state_for_event(
|
||||
historical_state = await self.state_storage.get_state_for_event(
|
||||
event_id, StateFilter.from_types((type_state_key,))
|
||||
)
|
||||
sender_state_event = historical_state.get(type_state_key)
|
||||
|
@ -127,7 +127,7 @@ class StateHandler:
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
self.clock = hs.get_clock()
|
||||
self.store = hs.get_datastores().main
|
||||
self.state_store = hs.get_storage().state
|
||||
self.state_storage = hs.get_storage().state
|
||||
self.hs = hs
|
||||
self._state_resolution_handler = hs.get_state_resolution_handler()
|
||||
self._storage = hs.get_storage()
|
||||
@ -339,7 +339,7 @@ class StateHandler:
|
||||
#
|
||||
|
||||
if not state_group_before_event:
|
||||
state_group_before_event = await self.state_store.store_state_group(
|
||||
state_group_before_event = await self.state_storage.store_state_group(
|
||||
event.event_id,
|
||||
event.room_id,
|
||||
prev_group=state_group_before_event_prev_group,
|
||||
@ -384,7 +384,7 @@ class StateHandler:
|
||||
state_ids_after_event[key] = event.event_id
|
||||
delta_ids = {key: event.event_id}
|
||||
|
||||
state_group_after_event = await self.state_store.store_state_group(
|
||||
state_group_after_event = await self.state_storage.store_state_group(
|
||||
event.event_id,
|
||||
event.room_id,
|
||||
prev_group=state_group_before_event,
|
||||
@ -418,7 +418,7 @@ class StateHandler:
|
||||
"""
|
||||
logger.debug("resolve_state_groups event_ids %s", event_ids)
|
||||
|
||||
state_groups = await self.state_store.get_state_group_for_events(event_ids)
|
||||
state_groups = await self.state_storage.get_state_group_for_events(event_ids)
|
||||
|
||||
state_group_ids = state_groups.values()
|
||||
|
||||
@ -426,8 +426,8 @@ class StateHandler:
|
||||
state_group_ids_set = set(state_group_ids)
|
||||
if len(state_group_ids_set) == 1:
|
||||
(state_group_id,) = state_group_ids_set
|
||||
state = await self.state_store.get_state_for_groups(state_group_ids_set)
|
||||
prev_group, delta_ids = await self.state_store.get_state_group_delta(
|
||||
state = await self.state_storage.get_state_for_groups(state_group_ids_set)
|
||||
prev_group, delta_ids = await self.state_storage.get_state_group_delta(
|
||||
state_group_id
|
||||
)
|
||||
return _StateCacheEntry(
|
||||
@ -441,7 +441,7 @@ class StateHandler:
|
||||
|
||||
room_version = await self.store.get_room_version_id(room_id)
|
||||
|
||||
state_to_resolve = await self.state_store.get_state_for_groups(
|
||||
state_to_resolve = await self.state_storage.get_state_for_groups(
|
||||
state_group_ids_set
|
||||
)
|
||||
|
||||
|
@ -50,7 +50,7 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
|
||||
hs = self.setup_test_homeserver(federation_http_client=None)
|
||||
self.handler = hs.get_federation_handler()
|
||||
self.store = hs.get_datastores().main
|
||||
self.state_store = hs.get_storage().state
|
||||
self.state_storage = hs.get_storage().state
|
||||
self._event_auth_handler = hs.get_event_auth_handler()
|
||||
return hs
|
||||
|
||||
@ -334,7 +334,7 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
|
||||
# mapping from (type, state_key) -> state_event_id
|
||||
assert most_recent_prev_event_id is not None
|
||||
prev_state_map = self.get_success(
|
||||
self.state_store.get_state_ids_for_event(most_recent_prev_event_id)
|
||||
self.state_storage.get_state_ids_for_event(most_recent_prev_event_id)
|
||||
)
|
||||
# List of state event ID's
|
||||
prev_state_ids = list(prev_state_map.values())
|
||||
|
Loading…
Reference in New Issue
Block a user