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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     1
#!/bin/bash
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     2
# 
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     3
# remove a list of events from a specific room
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     4
#
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     5
# create event list like:
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     6
#  sudo -u postgres psql synapse -Atc \
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     7
#   "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
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     8
#
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     9
#
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    10
. ./_config.sh
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    11
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    12
room_id="!NrRVEWbxnLuHdvlPhM:grin.hu"
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    13
reason="spamming"
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    14
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    15
f_event="events.data"
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    16
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    17
cat $f_event | while read evt; do
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    18
	#echo "== event: $evt =="
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    19
	method='PUT'
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    20
	data="{\"reason\":\"${reason}\"}"
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    21
	cmd="/_matrix/client/v3/rooms/${room_id}/redact/${evt}/"`uuid`
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    22
	#echo "${method} $cmd $data"
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    23
	curl -d "${data}" -X "${method}" -H "Authorization: Bearer ${T}" "${SRV}${cmd}"
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    24
done
3336c2c14bae Add mass_event_remove.sh: simple script redact events collected from the db
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    25