Skip to content

Instantly share code, notes, and snippets.

@ara4n
Last active December 7, 2022 00:12
Show Gist options
  • Save ara4n/968cd50d6ccec46da51e875a54396943 to your computer and use it in GitHub Desktop.
Save ara4n/968cd50d6ccec46da51e875a54396943 to your computer and use it in GitHub Desktop.
Bulk reject Matrix invites
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
@uhoreg
Copy link

uhoreg commented Dec 6, 2016

Changing the sleep 1 in line 3 to sleep 4 or 5 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).

@ara4n
Copy link
Author

ara4n commented Dec 6, 2016

done :)

@Mikaela
Copy link

Mikaela commented Dec 9, 2016

What is access token and where do I get it?

Update: typelocalStorage.mx_access_token to Firefox developer console on riot.im tab.

@uhoreg
Copy link

uhoreg commented Dec 12, 2016

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.

@ara4n
Copy link
Author

ara4n commented Dec 15, 2016

This is now obsoleted by the bulk invite reject feature in settings on riot.im/develop

@ElonSatoshi
Copy link

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