mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 07:54:48 -04:00
Use RoomVersion
objects (#10934)
Various refactors to use `RoomVersion` objects instead of room version identifiers.
This commit is contained in:
parent
2be0fde3d6
commit
5279b9161b
5 changed files with 50 additions and 48 deletions
|
@ -18,10 +18,8 @@ import attr
|
|||
from nacl.signing import SigningKey
|
||||
|
||||
from synapse.api.constants import MAX_DEPTH
|
||||
from synapse.api.errors import UnsupportedRoomVersionError
|
||||
from synapse.api.room_versions import (
|
||||
KNOWN_EVENT_FORMAT_VERSIONS,
|
||||
KNOWN_ROOM_VERSIONS,
|
||||
EventFormatVersions,
|
||||
RoomVersion,
|
||||
)
|
||||
|
@ -197,24 +195,6 @@ class EventBuilderFactory:
|
|||
self.state = hs.get_state_handler()
|
||||
self._event_auth_handler = hs.get_event_auth_handler()
|
||||
|
||||
def new(self, room_version: str, key_values: dict) -> EventBuilder:
|
||||
"""Generate an event builder appropriate for the given room version
|
||||
|
||||
Deprecated: use for_room_version with a RoomVersion object instead
|
||||
|
||||
Args:
|
||||
room_version: Version of the room that we're creating an event builder for
|
||||
key_values: Fields used as the basis of the new event
|
||||
|
||||
Returns:
|
||||
EventBuilder
|
||||
"""
|
||||
v = KNOWN_ROOM_VERSIONS.get(room_version)
|
||||
if not v:
|
||||
# this can happen if support is withdrawn for a room version
|
||||
raise UnsupportedRoomVersionError()
|
||||
return self.for_room_version(v, key_values)
|
||||
|
||||
def for_room_version(
|
||||
self, room_version: RoomVersion, key_values: dict
|
||||
) -> EventBuilder:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue