-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow events to be created with no prev_events
(MSC2716)
#11243
Changes from 1 commit
39efad1
66f0859
9f45d09
e093481
4bb5fd3
f421a2d
d10625e
2370dca
e2928b5
85364c5
0ed300e
93ca0f8
9b9deff
8fada7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -949,14 +949,24 @@ async def create_new_client_event( | |
else: | ||
prev_event_ids = await self.store.get_prev_events_for_room(builder.room_id) | ||
|
||
# we now ought to have some prev_events (unless it's a create event). | ||
# | ||
# do a quick sanity check here, rather than waiting until we've created the | ||
# Do a quick sanity check here, rather than waiting until we've created the | ||
# event and then try to auth it (which fails with a somewhat confusing "No | ||
# create event in auth events") | ||
assert ( | ||
builder.type == EventTypes.Create or len(prev_event_ids) > 0 | ||
), "Attempting to create an event with no prev_events" | ||
room_version_obj = await self.store.get_room_version(builder.room_id) | ||
if room_version_obj.msc2716_empty_prev_events: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Does this actually require a new room version? (discussed at #11114 (comment)) My thinking is that this code is only for creating events, not accepting events. So technically any other homeserver nowadays can create events with no Am I missing something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not that surprised that we accept outliers with empty prev-events, but we'll need special handling for the insertion event to be accepted, i.e. we'll need some sort of check like "this is an insertion event so we need to go and fetch the state rather than trying to calculate it". Though that can be part of the history import MSC I guess There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why is this the case? It seems to work in my Complement tests without any of this 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spooky! 👻 Is it doing something silly like dropping the event with no extremities and then doing a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure yet. If you really want me to dive into it, I can ⛳ |
||
# We allow events with no `prev_events` but it better have some `auth_events` | ||
assert ( | ||
builder.type == EventTypes.Create | ||
or len(prev_event_ids) > 0 | ||
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Allow an event to have empty list of prev_event_ids | ||
# only if it has auth_event_ids. | ||
or (auth_event_ids and len(auth_event_ids) > 0) | ||
erikjohnston marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), "Attempting to create an event with no prev_events or auth_event_ids" | ||
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else: | ||
# we now ought to have some prev_events (unless it's a create event). | ||
assert ( | ||
builder.type == EventTypes.Create or len(prev_event_ids) > 0 | ||
), "Attempting to create an event with no prev_events" | ||
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
event = await builder.build( | ||
prev_event_ids=prev_event_ids, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @anoadragon453 🦈