Room Upgrades
From time to time, a room may need to be upgraded to a different room version for a variety of reasons. This module defines a way for rooms to upgrade to a different room version when needed.
Events
m.room.tombstone
A state event signifying that a room has been upgraded to a different room version, and that clients should go there.
m.room.tombstone
| Event type: | State event |
|---|---|
| State key | A zero-length string. |
Content
| Name | Type | Description |
|---|---|---|
body |
string |
Required: A server-defined message. |
replacement_room |
string |
Required: The room ID of the new room the client should be visiting. |
Examples
{
"content": {
"body": "This room has been replaced",
"replacement_room": "!newroom:example.org"
},
"event_id": "$143273582443PhrSn:example.org",
"origin_server_ts": 1432735824653,
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
"sender": "@example:example.org",
"state_key": "",
"type": "m.room.tombstone",
"unsigned": {
"age": 1234
}
}
Client behaviour
Clients which understand m.room.tombstone events and the predecessor
field on m.room.create events should communicate to the user that the
room was upgraded. One way of accomplishing this would be hiding the old
room from the user’s room list and showing banners linking between the
old and new room - ensuring that permalinks work when referencing the
old room. Another approach may be to virtually merge the rooms such that
the old room’s timeline seamlessly continues into the new timeline
without the user having to jump between the rooms.
POST
/_matrix/client/v3/rooms/{roomId}/upgrade
Upgrades the given room to a particular room version.
| Rate-limited: | No |
|---|---|
| Requires authentication: | Yes |
Request
Request parameters
| Name | Type | Description |
|---|---|---|
roomId |
string |
Required: The ID of the room to upgrade. |
Request body
| Name | Type | Description |
|---|---|---|
new_version |
string |
Required: The new version for the room. |
Request body example
{
"new_version": "2"
}
Responses
| Status | Description |
|---|---|
200 |
The room was successfully upgraded. |
400 |
The request was invalid. One way this can happen is if the room version requested is not supported by the homeserver. |
403 |
The user is not permitted to upgrade the room. |
200 response
| Name | Type | Description |
|---|---|---|
replacement_room |
string |
Required: The ID of the new room. |
{
"replacement_room": "!newroom:example.org"
}
400 response
| Name | Type | Description |
|---|---|---|
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_UNSUPPORTED_ROOM_VERSION",
"error": "This server does not support that room version"
}
403 response
| Name | Type | Description |
|---|---|---|
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_FORBIDDEN",
"error": "You cannot upgrade this room"
}
Server behaviour
When the client requests to upgrade a known room to a known version, the server:
-
Checks that the user has permission to send
m.room.tombstoneevents in the room. -
[Changed in
v1.4] Creates a replacement room with am.room.createevent containing apredecessorfield, the applicableroom_version, and atypefield which is copied from thepredecessorroom. If notypeis set on the previous room, notypeis specified on the new room’s create event either. -
Replicates transferable state events to the new room. The exact details for what is transferred is left as an implementation detail, however the recommended state events to transfer are:
m.room.server_aclm.room.encryptionm.room.namem.room.avatarm.room.topicm.room.guest_accessm.room.history_visibilitym.room.join_rulesm.room.power_levels
Membership events should not be transferred to the new room due to technical limitations of servers not being able to impersonate people from other homeservers. Additionally, servers should not transfer state events which are sensitive to who sent them, such as events outside of the Matrix namespace where clients may rely on the sender to match certain criteria.
-
Moves any local aliases to the new room.
-
Sends a
m.room.tombstoneevent to the old room to indicate that it is not intended to be used any further. -
If possible, the power levels in the old room should also be modified to prevent sending of events and inviting new users. For example, setting
events_defaultandinviteto the greater of50andusers_default + 1.
When a user joins the new room, the server should automatically transfer/replicate some of the user’s personalized settings such as notifications, tags, etc.