Add matrix-purge-rooms

This commit is contained in:
Rob Watson 2022-06-10 14:41:54 +02:00
parent a433383074
commit d81052b967
1 changed files with 14 additions and 0 deletions

14
script/matrix-purge-rooms Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
#
# matrix-purge-rooms purges Matrix rooms with no users.
# Expects to connect to Synapse on localhost:8008.
set -euo pipefail
IFS=$'\n\t'
roomstopurge=$(curl -s --header "Authorization: Bearer $SYNAPSE_ACCESS_TOKEN" 'http://localhost:8008/_synapse/admin/v1/rooms?limit=300' | jq -r '.rooms[] | select(.joined_local_members == 0) | .room_id')
for roomid in $roomstopurge; do
echo "Purging room: $roomid"
curl -X DELETE -H "Authorization: Bearer $SYNAPSE_ACCESS_TOKEN" -H "Content-Type: application/json" -d "{\"purge\": true, \"force_purge\": true}" "http://localhost:8008/_synapse/admin/v1/rooms/$roomid"
echo
done