Fix logic flaw preventing tracking of MSC2716 events in existing room versions (#10962)

We correctly allowed using the MSC2716 batch endpoint for
the room creator in existing room versions but accidentally didn't track
the events because of a logic flaw.

This prevented you from connecting subsequent chunks together because it would
throw the unknown batch ID error.

We only want to process MSC2716 events when:

 - The room version supports MSC2716
 - Any room where the homeserver has the `msc2716_enabled` experimental feature enabled and the event is from the room creator
This commit is contained in:
Eric Eastwood 2021-10-05 11:51:57 -05:00 committed by GitHub
parent 2faac70e63
commit 392863fbf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

1
changelog.d/10962.bugfix Normal file
View File

@ -0,0 +1 @@
Fix [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) `/batch_send` endpoint rejecting subsequent batches with unknown batch ID error in existing room versions from the room creator.

View File

@ -1015,9 +1015,8 @@ class FederationEventHandler:
room_version = await self._store.get_room_version(marker_event.room_id) room_version = await self._store.get_room_version(marker_event.room_id)
create_event = await self._store.get_create_event_for_room(marker_event.room_id) create_event = await self._store.get_create_event_for_room(marker_event.room_id)
room_creator = create_event.content.get(EventContentFields.ROOM_CREATOR) room_creator = create_event.content.get(EventContentFields.ROOM_CREATOR)
if ( if not room_version.msc2716_historical and (
not room_version.msc2716_historical not self._config.experimental.msc2716_enabled
or not self._config.experimental.msc2716_enabled
or marker_event.sender != room_creator or marker_event.sender != room_creator
): ):
return return

View File

@ -1763,9 +1763,8 @@ class PersistEventsStore:
retcol="creator", retcol="creator",
allow_none=True, allow_none=True,
) )
if ( if not room_version.msc2716_historical and (
not room_version.msc2716_historical not self.hs.config.experimental.msc2716_enabled
or not self.hs.config.experimental.msc2716_enabled
or event.sender != room_creator or event.sender != room_creator
): ):
return return
@ -1825,9 +1824,8 @@ class PersistEventsStore:
retcol="creator", retcol="creator",
allow_none=True, allow_none=True,
) )
if ( if not room_version.msc2716_historical and (
not room_version.msc2716_historical not self.hs.config.experimental.msc2716_enabled
or not self.hs.config.experimental.msc2716_enabled
or event.sender != room_creator or event.sender != room_creator
): ):
return return