Metadata-Version: 2.4
Name: synapse-http-antispam
Version: 0.1.0
Summary: A Synapse module that forwards spam checking to an HTTP server
Project-URL: Repository, https://github.com/maunium/synapse-http-antispam
Project-URL: Bug Tracker, https://github.com/maunium/synapse-http-antispam/issues
Author-email: Tulir Asokan <tulir@maunium.net>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: matrix-synapse>=1.125.0
Description-Content-Type: text/markdown

# synapse-http-antispam
A Synapse spam checker module that forwards requests to an HTTP server.

## Installation
```
pip install synapse-http-antispam
```

or

```
pip install git+https://github.com/maunium/synapse-http-antispam#egg=synapse-http-antispam
```

## Configuration
Add the following to your `homeserver.yaml`:

```yaml
modules:
  - module: synapse_http_antispam.HTTPAntispam
    config:
      base_url: http://localhost:8080
      enabled_callbacks:
        - user_may_invite
```

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` are available.

The module will make HTTP requests to `<base_url>/<callback_name>` with all function parameters as JSON fields.

Any 2xx response will be return `NOT_SPAM` to Synapse and the response body will be ignored.

Any other response is treated as a rejection. The response body must be JSON and will be returned to the client as is.
If the `errcode` field is not present, 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.
