Last active
December 7, 2022 00:12
-
-
Save ara4n/968cd50d6ccec46da51e875a54396943 to your computer and use it in GitHub Desktop.
Bulk reject Matrix invites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
access_token=SECRET | |
# if your sync is large you may need to run this a few times until it completes rather than storing a timeout error | |
curl "https://matrix.org/_matrix/client/r0/sync?access_token=$access_token" > sync.json | |
for i in `cat sync.json | jq -r '.rooms.invite|keys|join(" ")'` | |
do echo $i | |
curl "https://matrix.org/_matrix/client/r0/rooms/$i/leave?access_token=$access_token" --data '{}' | |
sleep 5 | |
done |
done :)
What is access token and where do I get it?
Update: typelocalStorage.mx_access_token
to Firefox developer console on riot.im tab.
Also, changing the first curl command to curl -v -H "Accept-Encoding: gzip" "https://matrix.org/_matrix/client/r0/sync?access_token=$access_token" | gunzip > sync.json
will speed up downloading the initial sync.
This is now obsoleted by the bulk invite reject feature in settings on riot.im/develop
If anyone is here looking for a way to bulk reject invites because they can't find such an option in Element anymore, it still exists. It won't show up until you actually have at least one pending invite.
You will find it in Security and Privacy, just scroll down to Bulk Options, right before Encryption.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changing the
sleep 1
in line 3 tosleep 4
or5
may help to avoid rate limiting.Debian users may need to
apt install jq
if it isn't already installed (users of other distributions may need to do something similar).