Synapse Invite Checker

Synapse Invite Checker is a synapse module to restrict invites on a homeserver according to the rules required by Gematik in a TIM federation.
Table of Contents
Installation
pip install synapse-invite-checker
Configuration
Here are the available configuration options:
modules:
- module: "synapse_invite_checker.InviteChecker"
config:
title: "TIM Contact API by Famedly",
description: "Custom description for the endpoint",
contact: "random@example.com",
federation_list_url: "https://localhost:8080",
federation_list_client_cert: "tests/certs/client.pem",
federation_list_require_mtls: true or false,
gematik_ca_baseurl: "https://download-ref.tsl.ti-dienste.de/",
tim-type: "epa" or "pro",
default_permissions:
defaultSetting: "allow all" or "block all"
serverExceptions:
"<server_name>":
"@LOCAL_SERVER@":
userExceptions:
"<mxid>":
"@user:some_server.com":
groupException:
- groupName: "isInsuredPerson"
allowed_room_versions:
- "9"
- "10"
room_scan_run_interval: see 'Duration Parsing' below,
insured_only_room_scan:
enabled: true or false
grace_period: see 'Duration Parsing' below,
invites_grace_period: see 'Duration Parsing' below,
inactive_room_scan:
enabled: true or false
grace_period: see 'Duration Parsing' below
override_public_room_federation: true or false,
prohibit_world_readable_rooms: true or false,
block_invites_into_dms: true or false,
limit_reactions: true or false,
default_permissions
For establishing the default permissions for the users on this server. As the simplest
example:
default_permissions:
defaultSetting: "allow all"
This is what the default will be if no setting is entered for this section.
an example to allow all communication except for insured users
default_permissions:
defaultSetting: "allow all"
groupException:
- groupName: "isInsuredPerson"
and an example of blocking all communication except for users on the local server
default_permissions:
defaultSetting: "block all"
serverExceptions:
"@LOCAL_SERVER@":
Duration Parsing
Settings labeled as 'duration_parsing' allow for a string representation of the value
that is converted to milliseconds. Suffixes with 's', 'm', 'h', 'd', 'w', or 'y' may be used. For example:
1h
would translate to 3600000
milliseconds
Testing
To create virtual env and install dependency:
hatch shell
The tests uses twisted's testing framework trial, with the development
environment managed by hatch. Running the tests and generating a coverage report
can be done like this:
hatch run cov
Code Quality
Use hatch fmt
to automatically format code, enforce style rules, and check types using:
black
and isort
for formatting
ruff
for linting
mypy
for static type checking
Check Code Without Modifying It
To check code quality without modifying files:
- Check formatting with
isort
and black
:
hatch fmt --check -f
- Check types and linting with
mypy
and ruff
:
hatch fmt --check -l
- Check all of above, formatting, linting, and typing:
hatch fmt --check
Auto-formatting Code
To automatically fix issues in the code:
- Format only using
black
and isort
:
hatch fmt -f
- Type checks(
mypy
) and lint, fixing autofixable ruff
issues:
hatch fmt -l
- Run all tools, format, lint, type-check:
hatch fmt
License
synapse-invite-checker
is distributed under the terms of the
AGPL-3.0 license.