A small tool to merge, compare and deploy blocklist updates to a Fediverse server using its API. Currently tested on Mastodon and GoToSocial
Go to file
2023-12-19 09:24:02 +01:00
assets Add some documentation 2023-01-12 08:40:25 +01:00
fediverse_blocklist_deploy feat: Add package version 2023-12-19 09:21:06 +01:00
tests test: Add test infrastructure and basic model testing 2023-07-26 14:35:57 +02:00
.drone.yml test: Add test infrastructure and basic model testing 2023-07-26 14:35:57 +02:00
.gitignore Remove personal files and readd 2023-01-09 13:25:35 +01:00
blocklist.toml Change key names to comply with API names 2023-01-09 08:41:16 +01:00
DEVELOPMENT.md Rename from mastodon->fediverse 2023-07-26 12:43:34 +02:00
Dockerfile Rename from mastodon->fediverse 2023-07-26 12:43:34 +02:00
LICENSE Initial commit 2023-01-05 15:21:59 +01:00
poetry.lock test: Add test infrastructure and basic model testing 2023-07-26 14:35:57 +02:00
pyproject.toml docs: Adjust pyproject description 2023-12-19 09:24:02 +01:00
README.md Rename from mastodon->fediverse 2023-07-26 12:43:34 +02:00

fediverse-blocklist-deploy

A small tool to deploy blocklist updates to a fediverse server using its API.

Concept

The idea is to maintain a blocklist in a simple structured file in this repository. All changes need to be deployed to the fediverse server, this is supposed to be automated with Drone CI.

In order to compare the list entries, we can read the whole blocklist using the get endpoint. At the same time we read the whole file in the repository, make a comparison and remove unblocked domains from the blocklist and add newly added.

Since we have several attributes for a domain block, a simple .txt file might not be sufficient. We probably want to set the severity, reject_media, reject_reports and comments. This means we need a human-readable, easily python-readable and structured file format. Since Python 3.11 got native support for toml and it supports Array of Tables, I'd prefer to use this.

Supported server types

  • Mastodon
  • GoToSocial

Basic usage

usage: fediverse_blocklist_deploy [-h] [-s SERVER] [-t TOKEN] [-i INPUT_FILE] [-r REMOTE_BLOCKLIST] [-o OUTPUT] [-v] [-n]
                                 [--format FORMAT] [--private]
                                 {diff,deploy,export}

Deploy blocklist updates to a fediverse server

positional arguments:
  {diff,deploy,export}  Either use 'diff' to check the difference between local blockĺist and the blocklist on the server, 'deploy'
                        to apply the current local blocklist or 'export' to export the remote blocklist into a local file.

options:
  -h, --help            show this help message and exit
  -s SERVER, --server SERVER
                        The address of the server where you want to deploy (e.g. mastodon.social)
  -t TOKEN, --token TOKEN
                        Authorization token
  -i INPUT_FILE, --input-file INPUT_FILE
                        The blocklist to use
  -r REMOTE_BLOCKLIST, --remote-blocklist REMOTE_BLOCKLIST
                        The remote blocklist as json for debugging reasons
  -o OUTPUT, --output OUTPUT
                        Filename where to export the blocklist
  -v, --verbose
  -n, --no-delete       Do not delete existing blocks
  --format FORMAT       Export format: toml|markdown|csv|json
  --private             When the flag is set, private comment will also be exported.

Obtain a server token

  1. Be an admin on the server.
  2. Add an application in the Mastodon Web Client (https://yourdomain.org/settings/applications/new. Make sure to select the permissions admin:read and admin:write.
  3. Copy the Token (last value in the table)

Typical workflow

  1. Export the current blocklist from the server
fediverse_blocklist_deploy export -s yourserver -t yourtoken -o blocklist.toml
  1. Manually add something to the blocklist
[[instances]]
name = "instance-to-block.com"
domain = "instance-to-block.com"
severity = "suspend"
reject_media = true
reject_reports = true
public_comment = "X, Y and Z"
private_comment = "We discussed this after X and Y and now that Z happend we decided to block"
  1. Check the difference between the local and remote blocklist
fediverse_blocklist_deploy diff -s yourserver -t yourtoken -i blocklist.toml
  1. Apply the local blocklist to the server
fediverse_blocklist_deploy apply -s yourserver -t yourtoken -i blocklist.toml