update README's

This commit is contained in:
creme 2025-02-14 12:22:17 +01:00
parent d79aa5fe32
commit 1d2ee4e3ad
No known key found for this signature in database
GPG Key ID: C147C3B7FBDF08D0
2 changed files with 51 additions and 32 deletions

View File

@ -4,15 +4,10 @@
more informations on https://envs.net/chat/matrix/ more informations on https://envs.net/chat/matrix/
**synapse blocklist tool:**
An collection of modules for Synapse to block temporary email addresses and block invite-spam.
see: https://git.envs.net/envs/synapse_blocklist_module
## useful documentations ## useful documentations
\- [matrix-spec](https://matrix.org/docs/spec/) \- [matrix-spec](https://spec.matrix.org/latest/)
\- [synapse INSTALL.md](https://github.com/matrix-org/synapse/blob/master/docs/setup/installation.md) \- [synapse INSTALL.md](https://github.com/matrix-org/synapse/blob/master/docs/setup/installation.md)
\- [synapse default homeserver.yaml](https://github.com/matrix-org/synapse/blob/master/docs/sample_config.yaml) \- [synapse default homeserver.yaml](https://github.com/matrix-org/synapse/blob/master/docs/sample_config.yaml)
@ -24,3 +19,17 @@ see: https://git.envs.net/envs/synapse_blocklist_module
\- [matrix-synchrotron-balancer](https://github.com/Sorunome/matrix-synchrotron-balancer) \- [matrix-synchrotron-balancer](https://github.com/Sorunome/matrix-synchrotron-balancer)
\- [matrix-media-repo](https://github.com/turt2live/matrix-media-repo) \- [matrix-media-repo](https://github.com/turt2live/matrix-media-repo)
## useful tools
### envs - synapse blocklist tool
An collection of modules for Synapse to block temporary email addresses and invite-spam.
see: https://git.envs.net/envs/synapse_blocklist_module
### synadm
Command line admin tool for Synapse
repo: [https://github.com/JOJ0/synadm](https://github.com/JOJ0/synadm)

View File

@ -1,8 +1,12 @@
# useful aliases # useful aliases
**deps.:**
install moreutils
`apt install moreutils`
simple add it to your alias file. simple add it to your alias file.
**deps.:**
``` ```
source "$HOME/.token" # contains $token source "$HOME/.token" # contains $token
server='server.tld' server='server.tld'
@ -28,11 +32,15 @@ matrix-show_users() {
```bash ```bash
matrix-deactivate-users() { matrix-deactivate-users() {
while read i; do if [ -s ~/deactivate_users.txt ]; then
printf '%s\n' "$i"; \ while read i; do
curl -s -H "Authorization: Bearer $token" -X POST 'https://'"$server"'/_synapse/admin/v1/deactivate/'"$i" -d '{"erase": true}'; printf '\n' printf '%s\n' "$i"; \
done < ~/deactivate_users.txt curl -s -H "Authorization: Bearer $token" -X POST 'https://'"$server"'/_synapse/admin/v1/deactivate/'"$i" -d '{"erase": true}'; printf '\n'
echo > ~/deactivate_users.txt done < ~/deactivate_users.txt
echo > ~/deactivate_users.txt
else
printf '~/deactivate_users.txt is empty.\n'
fi
} }
``` ```
@ -42,7 +50,6 @@ matrix-deactivate-users() {
matrix-remove-empty-rooms() { matrix-remove-empty-rooms() {
TOPURGE=$(curl -s -H "Authorization: Bearer $token" -X GET \ TOPURGE=$(curl -s -H "Authorization: Bearer $token" -X GET \
'https://'"$server"'/_synapse/admin/v1/rooms?limit=1000000' | jq -Mr '.rooms[] | select(.joined_local_members == 0) | .room_id') 'https://'"$server"'/_synapse/admin/v1/rooms?limit=1000000' | jq -Mr '.rooms[] | select(.joined_local_members == 0) | .room_id')
for i in $TOPURGE; do for i in $TOPURGE; do
printf 'processing room %s ..\n' "$i" printf 'processing room %s ..\n' "$i"
curl -s -w "\nResponse code: %{response_code}\n" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -X DELETE -d '{}' \ curl -s -w "\nResponse code: %{response_code}\n" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -X DELETE -d '{}' \
@ -55,20 +62,24 @@ matrix-remove-empty-rooms() {
```bash ```bash
matrix-purge-rooms() { matrix-purge-rooms() {
echo > ~/blocked_members.txt if [ -s ~/purge_rooms.txt ]; then
while read i; do echo > ~/blocked_members.txt
printf '%s\n' "$i" while read i; do
curl -s -H "Authorization: Bearer $token" -X GET 'https://'"$server"'/_synapse/admin/v1/rooms/'"$i"'/members' | jq -Mr .members[] >> ~/blocked_members.txt printf '%s\n' "$i"
curl -s -H "Authorization: Bearer $token" -X DELETE 'https://'"$server"'/_synapse/admin/v1/rooms/'"$i" -d '{"purge": true, "block": true}' curl -s -H "Authorization: Bearer $token" -X GET 'https://'"$server"'/_synapse/admin/v1/rooms/'"$i"'/members' | jq -Mr .members[] >> ~/blocked_members.txt >/dev/null 2>&1
printf '\n' curl -s -H "Authorization: Bearer $token" -X DELETE 'https://'"$server"'/_synapse/admin/v1/rooms/'"$i" -d '{"purge": true, "block": true}'
done < ~/purge_rooms.txt printf '\n'
sed -i -e '/^$/d' ~/blocked_members.txt done < ~/purge_rooms.txt
sort -u -o ~/blocked_members.txt{,} sed -i -e '/^$/d' ~/blocked_members.txt
for i in $(grep "$server" ~/blocked_members.txt); do sort -u -o ~/blocked_members.txt{,}
printf '%s\n' "$i" for i in $(grep "$server" ~/blocked_members.txt); do
curl -s -H "Authorization: Bearer $token" -X POST 'https://'"$server"'/_synapse/admin/v1/deactivate/'"$i" -d '{"erase": true}' printf '%s\n' "$i"
done curl -s -H "Authorization: Bearer $token" -X POST 'https://'"$server"'/_synapse/admin/v1/deactivate/'"$i" -d '{"erase": true}'
sed -i '/'"$server"'/d' ~/blocked_members.txt done
sed -i '/'"$server"'/d' ~/blocked_members.txt
else
printf '~/purge_rooms.txt is empty.\n'
fi
} }
``` ```
@ -76,9 +87,8 @@ matrix-purge-rooms() {
```bash ```bash
matrix-get-blocked_rooms() { matrix-get-blocked_rooms() {
sudo -iu postgres psql -d matrix -c "SELECT room_id FROM blocked_rooms" > ~/blocked_rooms.tmp sudo -iu postgres psql -d matrix -c "SELECT room_id FROM blocked_rooms" > ~/blocked_rooms.txt
sed -i -e 's/ //' -e '1,2d' ~/blocked_rooms.tmp sed -i -e 's/ //' -e '1,2d' ~/blocked_rooms.txt
head -n -2 ~/blocked_rooms.tmp > ~/blocked_rooms.txt head -n -2 ~/blocked_rooms.txt | sponge ~/blocked_rooms.txt
rm ~/blocked_rooms.tmp
} }
``` ```