Browse Source

add matrix-upgrade-room.bash

master
Mikaela Suomalainen 6 days ago
parent
commit
14551cb4dd
Signed by: mikaela <mikaela@mikaela.info> GPG Key ID: 99392F62BAE30723
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      bash/matrix-upgrade-room.bash

+ 23
- 0
bash/matrix-upgrade-room.bash View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Based on https://gist.github.com/turt2live/a99c8e794d6115d4ddfaadb72aabf063

# TODO: Find out where the latest version can be found out from
ROOMVERSION=5
ACCESSTOKEN=
NEWROOMNAME=""
OLDROOMID=
# Note: $ is not a character that worlks without quotes due to signifying a
# variable
LASTEVENTINOLDROOM=''
HOMESERVER=chat.privacytools.io

set -x

# Creating the new room pointing to old one
# Thanks to https://gist.github.com/turt2live/a99c8e794d6115d4ddfaadb72aabf063#gistcomment-3071780 for the awk
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/r0/createRoom | awk -F\" '{ printf $4 }')

# Sending a tombstone
curl -s -X PUT -H "Authorization: Bearer $ACCESSTOKEN" -H "Content-Type: application/json" --data-binary "{\"replacement_room\":\"$NEWROOMID\"}" "https://$HOMESERVER/_matrix/client/r0/rooms/$OLDROOMID/state/m.room.tombstone"
set +x

Loading…
Cancel
Save