Skip to main content

A Synapse module that forwards spam checking to an HTTP server

Project description

synapse-http-antispam

A Synapse spam checker module that forwards requests to an HTTP server.

Discussion

This project was written for use with Meowlnir, so it can be discussed in the Meowlnir room: #meowlnir:maunium.net

Installation

pip install synapse-http-antispam

or

pip install synapse-http-antispam@git+https://github.com/maunium/synapse-http-antispam.git

Configuration

Add the following to your homeserver.yaml:

modules:
  - module: synapse_http_antispam.HTTPAntispam
    config:
      base_url: http://localhost:8080
      authorization: random string
      enabled_callbacks:
        - user_may_invite
      async:
        user_may_join_room: true
      fail_open:
        check_event_for_spam: true

If enabled_callbacks is not specified, all callbacks will be enabled.

See https://element-hq.github.io/synapse/v1.126/modules/spam_checker_callbacks.html for the list of available callbacks. All callbacks except check_media_file_for_spam, check_registration_for_spam and should_drop_federated_event are available.

The module will make HTTP requests to <base_url>/<callback_name> with all function parameters as JSON fields. The authorization field will be sent as a Authorization: Bearer <value> header if specified.

The response body must always be JSON. Any 2xx response will be return NOT_SPAM to Synapse. The content of 2xx responses is ignored, so an empty object is sufficient. Any other response is treated as a rejection and the response body will be returned to the client as-is. If the errcode field is not present in error responses, it will default to M_FORBIDDEN.

If the server returns a non-JSON response or if the request fails, the module will fail closed and reject the callback with an M_UNKNOWN error by default, except for callbacks specified in fail_open. Additionally, the check_event_for_spam callback will fail open by default, unless set to false in fail_open.

Any callbacks set to true in the async map will be executed in the background and will always return NOT_SPAM to Synapse. The response status and data will be ignored for async callbacks.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synapse_http_antispam-0.3.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synapse_http_antispam-0.3.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file synapse_http_antispam-0.3.0.tar.gz.

File metadata

  • Download URL: synapse_http_antispam-0.3.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for synapse_http_antispam-0.3.0.tar.gz
Algorithm Hash digest
SHA256 78607b214d7c7e32d1bc0470621a5ae32d1db70819b48962a21ef7a1658e6b13
MD5 a5abfd70d09c2391e8218f7b89119eb8
BLAKE2b-256 5b6fbf32865819fc5fd8e82628db863215452f6669368c6d2b36a4c69bc53688

See more details on using hashes here.

File details

Details for the file synapse_http_antispam-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for synapse_http_antispam-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69d48fa96b1243381ccd1dea835fa9991438f111afce1e803c16cb5e5f261316
MD5 78082d11f02a69540549360cf16d2a03
BLAKE2b-256 9707fddfe868cec1c8fd971827376d0f2cdee02af7c8f2bcda117eff16f80f8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page