2020-02-11 19:50:58 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Based on https://gist.github.com/turt2live/a99c8e794d6115d4ddfaadb72aabf063
|
|
|
|
|
2022-05-15 19:56:52 +02:00
|
|
|
# Refer to https://spec.matrix.org/unstable/rooms/#complete-list-of-room-versions
|
|
|
|
# and room versions supported by your homeserver BEFORE adjusting/running this.
|
|
|
|
# Otherwise the target room version may be outdated or the last one I have
|
|
|
|
# ran this script for.
|
2023-08-20 10:02:16 +02:00
|
|
|
ROOMVERSION=11
|
2023-04-09 11:50:24 +02:00
|
|
|
# Help and about in Element Web settings
|
2020-02-11 19:50:58 +01:00
|
|
|
ACCESSTOKEN=
|
2022-05-15 19:56:52 +02:00
|
|
|
NEWROOMNAME="CHANGEME (v$ROOMVERSION)"
|
2023-04-09 11:49:12 +02:00
|
|
|
# https://develop.element.io (or other Element release), run /devtools and
|
|
|
|
# enable developer mode. Reads on top of /devtools and Room settings ->
|
|
|
|
# Advanced
|
2020-02-11 19:50:58 +01:00
|
|
|
OLDROOMID=
|
2023-04-09 11:49:12 +02:00
|
|
|
# When developer mode is enabled from /devtools in Element Web, visible in
|
|
|
|
# the hover menu when pointing a message and selecting "view event source".
|
|
|
|
# Note: $ is not a character that works without quotes due to signifying a
|
2020-02-11 19:50:58 +01:00
|
|
|
# variable
|
|
|
|
LASTEVENTINOLDROOM=''
|
2023-04-09 11:49:12 +02:00
|
|
|
# https://matrix.org/.well-known/matrix/client
|
2021-10-06 22:06:03 +02:00
|
|
|
HOMESERVER=matrix-client.matrix.org
|
2020-02-11 19:50:58 +01:00
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
# Creating the new room pointing to old one
|
|
|
|
# Thanks to https://gist.github.com/turt2live/a99c8e794d6115d4ddfaadb72aabf063#gistcomment-3071780 for the awk
|
2022-02-18 12:21:14 +01:00
|
|
|
NEWROOMID=$(curl -s -X POST -H "Authorization: Bearer $ACCESSTOKEN" -H "Content-Type: application/json" --data-binary "{\"name\":\"$NEWROOMNAME\",\"room_version\":\"$ROOMVERSION\",\"creation_content\":{\"predecessor\":{\"room_id\":\"$OLDROOMID\",\"event_id\":\"$LASTEVENTINOLDROOM\"}}}" https://$HOMESERVER/_matrix/client/v3/createRoom | awk -F\" '{ printf $4 }')
|
2020-02-11 19:50:58 +01:00
|
|
|
|
|
|
|
# Sending a tombstone
|
2022-02-18 12:21:14 +01:00
|
|
|
curl -s -X PUT -H "Authorization: Bearer $ACCESSTOKEN" -H "Content-Type: application/json" --data-binary "{\"replacement_room\":\"$NEWROOMID\"}" "https://$HOMESERVER/_matrix/client/v3/rooms/$OLDROOMID/state/m.room.tombstone"
|
2020-02-11 19:50:58 +01:00
|
|
|
set +x
|