synapse/mass_event_remove.sh
author Peter Gervai <grin@grin.hu>
Wed, 08 Mar 2023 22:27:54 +0100
changeset 12 3336c2c14bae
permissions -rwxr-xr-x
Add mass_event_remove.sh: simple script redact events collected from the db

#!/bin/bash
# 
# remove a list of events from a specific room
#
# create event list like:
#  sudo -u postgres psql synapse -Atc \
#   "SELECT event_id FROM events e LEFT JOIN event_json ej USING(event_id) WHERE e.room_id='"'!'"NrRVEWbxnLuHdvlPhM:grin.hu' AND ej.json ~ 'gorelol.ori-club.xyz'" > events.data
#
#
. ./_config.sh

room_id="!NrRVEWbxnLuHdvlPhM:grin.hu"
reason="spamming"

f_event="events.data"

cat $f_event | while read evt; do
	#echo "== event: $evt =="
	method='PUT'
	data="{\"reason\":\"${reason}\"}"
	cmd="/_matrix/client/v3/rooms/${room_id}/redact/${evt}/"`uuid`
	#echo "${method} $cmd $data"
	curl -d "${data}" -X "${method}" -H "Authorization: Bearer ${T}" "${SRV}${cmd}"
done