Skip to content

Instantly share code, notes, and snippets.

@ushitora-anqou
Created February 16, 2024 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ushitora-anqou/db86060b44893940fc65a045796c8e7f to your computer and use it in GitHub Desktop.
Save ushitora-anqou/db86060b44893940fc65a045796c8e7f to your computer and use it in GitHub Desktop.
#!/usr/bin/bash -xeu
set -o pipefail
DOMAIN=mstdn.anqou.net
ACCESS_TOKEN=
list-domains(){
curl -H "Authorization: Bearer ${ACCESS_TOKEN}" https://${DOMAIN}/api/v1/notifications | \
jq -r '.[].account.acct' | \
grep @ | \
sed -r 's/^[^@]*@(.*)/\1/' | \
sort -u
}
block-domain(){
curl -H "Authorization: Bearer ${ACCESS_TOKEN}" -H "Content-type: application/json" -d "{\"domain\":\"$1\",\"severity\":\"suspend\"}" https://${DOMAIN}/api/v1/admin/domain_blocks | jq
}
if [ $# -lt 1 ]; then
echo "Usage: $0 list-domains"
echo " $0 block-domain TARGET"
exit 1
fi
subcommand="$1"
shift
case "$subcommand" in
list-domains )
list-domains
;;
block-domain )
target="$1"
block-domain "$target"
;;
esac
@ushitora-anqou
Copy link
Author

LICENSE: CC0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment