matrix-org / matrix-spec

The Matrix protocol specification
Apache License 2.0
188 stars 94 forks source link

Setting power levels during room creation #1901

Open Johennes opened 3 months ago

Johennes commented 3 months ago

This is a mix of clarification and suggestion but since the two issues correlate I thought it'd be better to create a single issue.

Link to problem area:

https://spec.matrix.org/v1.11/client-server-api/#post_matrixclientv3createroom

Screenshot 2024-07-05 at 11 38 57

Issue

The /createRoom API provides clients with two options to set the m.room.power_levels event.

power_level_content_override is merged into the default power-level event and inserted as the first event after m.room.create and the room creator's m.room.member event.

Events in initial_state are inserted towards the end of room creation but before m.room.name, m.room.topic and any invites.

There are two issues here:

  1. Synapse doesn't follow this and instead inserts the power-level event from initial_state in the place where power_level_content_override should be applied, ignoring the former. According to https://github.com/matrix-org/synapse/issues/11731#issuecomment-1012304503 [^1] this is deemed the preferred behavior.
  2. Regardless of whether the order from the spec or from Synapse is used, it's not possible for a room creator to fully demote themselves at the end of room creation through /createRoom. With the spec'ed behavior, further state events are sent after initial_state which prevents taking away power levels for these events via initial_state. With Synapse's behavior, power levels can only be applied at the beginning of room creation which disables most if not all practical demotion options. While it's possible to demote yourself by sending another request after room creation, this makes the initial_state parameter less useful than it could be.

Suggestion

  1. The discrepancy between Synapse and the spec should be resolved.
  2. initial_state (or something similar) should be applied in step 8 rather than 6

[^1]: Note that this issue continues at https://github.com/element-hq/synapse/issues/11731

richvdh commented 3 months ago

@Johennes I think some words are missing from the issue title?

Johennes commented 3 months ago

Errm, yes sorry. Somehow I cut myself off there. Thanks for flagging. I fixed it.