Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Refactor state module to support multiple room versions #3673

Merged
merged 9 commits into from
Aug 22, 2018
1 change: 1 addition & 0 deletions changelog.d/3673.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor state module to support multiple room versions
9 changes: 7 additions & 2 deletions synapse/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ class ThirdPartyEntityKind(object):
LOCATION = "location"


class RoomVersions(object):
V1 = "1"
VDH_TEST = "vdh-test-version"


# the version we will give rooms which are created on this server
DEFAULT_ROOM_VERSION = "1"
DEFAULT_ROOM_VERSION = RoomVersions.V1

# vdh-test-version is a placeholder to get room versioning support working and tested
# until we have a working v2.
KNOWN_ROOM_VERSIONS = {"1", "vdh-test-version"}
KNOWN_ROOM_VERSIONS = {RoomVersions.V1, RoomVersions.VDH_TEST}
6 changes: 5 additions & 1 deletion synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ def fetch(ev_ids):
ev_ids, get_prev_content=False, check_redacted=False
)

room_version = yield self.store.get_room_version(pdu.room_id)
state_map = yield resolve_events_with_factory(
state_groups, {pdu.event_id: pdu}, fetch
room_version, state_groups, {pdu.event_id: pdu}, fetch
)

state = (yield self.store.get_events(state_map.values())).values()
Expand Down Expand Up @@ -1828,7 +1829,10 @@ def do_auth(self, origin, event, context, auth_events):
(d.type, d.state_key): d for d in different_events if d
})

room_version = yield self.store.get_room_version(event.room_id)

new_state = self.state_handler.resolve_events(
room_version,
[list(local_view.values()), list(remote_view.values())],
event
)
Expand Down
1 change: 1 addition & 0 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def _update_membership(
latest_event_ids = (
event_id for (event_id, _, _) in prev_events_and_hashes
)

current_state_ids = yield self.state_handler.get_current_state_ids(
room_id, latest_event_ids=latest_event_ids,
)
Expand Down
Loading