- 
          
- 
                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 3 commits
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 | 
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Allow experimental room version `org.matrix.msc2716v4` to allow events to be created without `prev_events` (only `auth_events`). | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -81,6 +81,8 @@ class RoomVersion: | |
| msc2716_historical = attr.ib(type=bool) | ||
| 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. 
 Thanks for the review @anoadragon453 🦈 | ||
| # MSC2716: Adds support for redacting "insertion", "chunk", and "marker" events | ||
| msc2716_redactions = attr.ib(type=bool) | ||
| # MSC2716: Adds support for events with no `prev_events` but with some `auth_events` | ||
| msc2716_empty_prev_events = attr.ib(type=bool) | ||
|  | ||
|  | ||
| class RoomVersions: | ||
|  | @@ -99,6 +101,7 @@ class RoomVersions: | |
| msc2403_knocking=False, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V2 = RoomVersion( | ||
| "2", | ||
|  | @@ -115,6 +118,7 @@ class RoomVersions: | |
| msc2403_knocking=False, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V3 = RoomVersion( | ||
| "3", | ||
|  | @@ -131,6 +135,7 @@ class RoomVersions: | |
| msc2403_knocking=False, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V4 = RoomVersion( | ||
| "4", | ||
|  | @@ -147,6 +152,7 @@ class RoomVersions: | |
| msc2403_knocking=False, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V5 = RoomVersion( | ||
| "5", | ||
|  | @@ -163,6 +169,7 @@ class RoomVersions: | |
| msc2403_knocking=False, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V6 = RoomVersion( | ||
| "6", | ||
|  | @@ -179,6 +186,7 @@ class RoomVersions: | |
| msc2403_knocking=False, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| MSC2176 = RoomVersion( | ||
| "org.matrix.msc2176", | ||
|  | @@ -195,6 +203,7 @@ class RoomVersions: | |
| msc2403_knocking=False, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V7 = RoomVersion( | ||
| "7", | ||
|  | @@ -211,6 +220,7 @@ class RoomVersions: | |
| msc2403_knocking=True, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V8 = RoomVersion( | ||
| "8", | ||
|  | @@ -227,6 +237,7 @@ class RoomVersions: | |
| msc2403_knocking=True, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| V9 = RoomVersion( | ||
| "9", | ||
|  | @@ -243,6 +254,7 @@ class RoomVersions: | |
| msc2403_knocking=True, | ||
| msc2716_historical=False, | ||
| msc2716_redactions=False, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| MSC2716v3 = RoomVersion( | ||
| "org.matrix.msc2716v3", | ||
|  | @@ -259,6 +271,24 @@ class RoomVersions: | |
| msc2403_knocking=True, | ||
| msc2716_historical=True, | ||
| msc2716_redactions=True, | ||
| msc2716_empty_prev_events=False, | ||
| ) | ||
| MSC2716v4 = RoomVersion( | ||
| "org.matrix.msc2716v4", | ||
| RoomDisposition.UNSTABLE, | ||
| EventFormatVersions.V3, | ||
| StateResolutionVersions.V2, | ||
| enforce_key_validity=True, | ||
| special_case_aliases_auth=False, | ||
| strict_canonicaljson=True, | ||
| limit_notifications_power_levels=True, | ||
| msc2176_redaction_rules=False, | ||
| msc3083_join_rules=False, | ||
| msc3375_redaction_rules=False, | ||
| msc2403_knocking=True, | ||
| msc2716_historical=True, | ||
| msc2716_redactions=True, | ||
| msc2716_empty_prev_events=True, | ||
| ) | ||
|  | ||
|  | ||
|  | @@ -276,6 +306,7 @@ class RoomVersions: | |
| RoomVersions.V8, | ||
| RoomVersions.V9, | ||
| RoomVersions.MSC2716v3, | ||
| RoomVersions.MSC2716v4, | ||
| ) | ||
| } | ||
|  | ||
|  | ||
| 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: | ||
|          | ||
| # 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.
              Outdated
          
            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.
              Outdated
          
            Show resolved
            Hide resolved | ||
| ), "Attempting to create an event with no prev_events or auth_event_ids" | ||
|         
                  MadLittleMods marked this conversation as resolved.
              Outdated
          
            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.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| event = await builder.build( | ||
| prev_event_ids=prev_event_ids, | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.