Add matrix-purge-rooms
This commit is contained in:
parent
a433383074
commit
d81052b967
|
@ -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
|
Loading…
Reference in New Issue