mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 17:46:08 +03:00
Handle to_delete
This commit is contained in:
parent
a1aaa47dad
commit
bf78692ba0
2 changed files with 26 additions and 9 deletions
|
@ -1286,16 +1286,30 @@ class PersistEventsStore:
|
|||
room_encryption_event_id = None
|
||||
room_name_event_id = None
|
||||
for state_key, event_id in to_insert.items():
|
||||
if state_key[0] == EventTypes.Create:
|
||||
if state_key[0] == EventTypes.Create and state_key[1] == "":
|
||||
create_event_id = event_id
|
||||
event_ids_to_fetch.append(event_id)
|
||||
elif state_key[0] == EventTypes.RoomEncryption:
|
||||
elif state_key[0] == EventTypes.RoomEncryption and state_key[1] == "":
|
||||
room_encryption_event_id = event_id
|
||||
event_ids_to_fetch.append(event_id)
|
||||
elif state_key[0] == EventTypes.Name:
|
||||
elif state_key[0] == EventTypes.Name and state_key[1] == "":
|
||||
room_name_event_id = event_id
|
||||
event_ids_to_fetch.append(event_id)
|
||||
|
||||
# Map of values to insert/update in the `sliding_sync_joined_rooms` table
|
||||
sliding_sync_joined_rooms_insert_map: Dict[
|
||||
str, Optional[Union[str, bool]]
|
||||
] = {}
|
||||
|
||||
# If something is being deleted from the state, we need to clear it out
|
||||
for event_type, state_key in to_delete:
|
||||
if event_type == EventTypes.Create and state_key == "":
|
||||
sliding_sync_joined_rooms_insert_map["room_type"] = None
|
||||
elif event_type == EventTypes.RoomEncryption and state_key == "":
|
||||
sliding_sync_joined_rooms_insert_map["is_encrypted"] = False
|
||||
elif event_type == EventTypes.Name and state_key == "":
|
||||
sliding_sync_joined_rooms_insert_map["room_name"] = None
|
||||
|
||||
# Fetch the events from the database
|
||||
event_json_rows = cast(
|
||||
List[Tuple[str, str]],
|
||||
|
@ -1309,9 +1323,6 @@ class PersistEventsStore:
|
|||
),
|
||||
)
|
||||
# Parse the raw event JSON
|
||||
sliding_sync_joined_rooms_insert_map: Dict[
|
||||
str, Optional[Union[str, bool]]
|
||||
] = {}
|
||||
for event_id, json in event_json_rows:
|
||||
event_json = db_to_json(json)
|
||||
|
||||
|
@ -1413,6 +1424,11 @@ class PersistEventsStore:
|
|||
membership_event_id_to_user_id_map[event_id] = state_key[1]
|
||||
|
||||
if len(membership_event_id_to_user_id_map) > 0:
|
||||
# Map of values to insert/update in the `sliding_sync_non_join_memberships` table
|
||||
sliding_sync_non_joined_rooms_insert_map: Dict[
|
||||
str, Optional[Union[str, bool]]
|
||||
] = {}
|
||||
|
||||
# Fetch the events from the database
|
||||
#
|
||||
# TODO: We should gather this data before we delete the
|
||||
|
@ -1442,9 +1458,6 @@ class PersistEventsStore:
|
|||
)
|
||||
|
||||
# Parse the raw event JSON
|
||||
sliding_sync_non_joined_rooms_insert_map: Dict[
|
||||
str, Optional[Union[str, bool]]
|
||||
] = {}
|
||||
for row in txn:
|
||||
event_id, event_type, state_key, json = row
|
||||
event_json = db_to_json(json)
|
||||
|
|
|
@ -856,6 +856,8 @@ class SlidingSyncPrePopulatedTablesTestCase(HomeserverTestCase):
|
|||
exact=True,
|
||||
)
|
||||
|
||||
# TODO: test_joined_room_state_reset
|
||||
|
||||
def test_non_join_space_room_with_info(self) -> None:
|
||||
"""
|
||||
Test users who was invited shows up in `sliding_sync_non_join_memberships`.
|
||||
|
@ -1109,3 +1111,5 @@ class SlidingSyncPrePopulatedTablesTestCase(HomeserverTestCase):
|
|||
},
|
||||
exact=True,
|
||||
)
|
||||
|
||||
# TODO: test_non_join_state_reset
|
||||
|
|
Loading…
Reference in a new issue