Created
February 16, 2024 03:41
-
-
Save ushitora-anqou/db86060b44893940fc65a045796c8e7f to your computer and use it in GitHub Desktop.
This file contains 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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LICENSE: CC0