-
-
Notifications
You must be signed in to change notification settings - Fork 97
Tombstoning a room on Matrix
Graham Christensen edited this page Feb 8, 2023
·
1 revision
This was used for tombstoning a room, and might be useful in the future:
# Access Token
- Element:
Settings > Help & About > Advanced > Access Token <click to reveal>
ACCESS_TOKEN=
# Usage
SERVER=$(curl -s https://matrix.org/.well-known/matrix/server | jq -j '."m.server"')
MATRIX_USER="@user:matrix.org"
curl -s -X GET -H "Authorization: Bearer ${ACCESS_TOKEN}" "https://${SERVER}/_matrix/client/r0/profile/${MATRIX_USER}/displayname"
# tombstone
- https://spec.matrix.org/v1.5/client-server-api/#room-upgrades
- https://hackmd.io/@ansible-community/rJ2qsdB1Y#Manually-upgrading-a-room
# ! = %21
# : = %3A
OLD_ROOM_ID='!tF11RlKMaCP0Cmio:thalheim.io'
OLD_SERVER=$(curl -s https://thalheim.io/.well-known/matrix/server | jq -j '."m.server"')
#NEW_SERVER=$(curl -s https://nixos.org/.well-known/matrix/server | jq -j '."m.server"')
NEW_SERVER=$(curl -s https://thalheim.io/.well-known/matrix/server | jq -j '."m.server"')
NEW_ROOM_ALIAS='nixos-anywhere'
NEW_ROOM_NAME='nixos-anywhere'
NEW_ROOM_TOPIC='install NixOS everywhere via ssh'
# Set initial tombstone event:
TOMBSTONE_EVENT=$(curl -XPUT --header "Authorization: Bearer ${ACCESS_TOKEN}" -H 'Content-Type: application/json' "https://${OLD_SERVER}/_matrix/client/r0/rooms/${OLD_ROOM_ID}/state/m.room.tombstone" -d '{ "replacement_room": "!notaroom:matrix.org" }' | jq -j .event_id)
# Create new room referencing tombstone event in OLD_ROOM_ID:
NEW_ROOM_ID=$(curl -XPOST --header "Authorization: Bearer ${ACCESS_TOKEN}" "https://${NEW_SERVER}/_matrix/client/r0/createRoom" -H 'Content-Type: application/json' -d '{ "preset": "public_chat", "room_alias_name": "'"${NEW_ROOM_ALIAS}"'", "name": "'"${NEW_ROOM_NAME}"'", "topic": "'"${NEW_ROOM_TOPIC}"'", "creation_content": { "predecessor": { "event_id": "'"${TOMBSTONE_EVENT}"'", "room_id": "'"${OLD_ROOM_ID}"'" } } }' | jq -j .room_id)
# Update tombstone event in OLD_ROOM_ID with NEW_ROOM_ID:
NEW_TOMBSTONE_EVENT=$(curl -XPUT --header "Authorization: Bearer ${ACCESS_TOKEN}" -H 'Content-Type: application/json' "https://${OLD_SERVER}/_matrix/client/r0/rooms/${OLD_ROOM_ID}/state/m.room.tombstone" -d '{ "replacement_room": "'"${NEW_ROOM_ID}"'" }')