Add support for synapse-http-antispam and integrate it with Draupnir
Supersedes https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/4284
This commit is contained in:
@ -1412,6 +1412,38 @@ matrix_synapse_ext_spam_checker_mjolnir_antispam_config:
|
||||
ban_lists: "{{ matrix_synapse_ext_spam_checker_mjolnir_antispam_config_ban_lists }}"
|
||||
message_max_length: "{{ matrix_synapse_ext_spam_checker_mjolnir_antispam_config_message_max_length }}"
|
||||
|
||||
# Enable this to activate the synapse-http-antispam module.
|
||||
# See: github.com/maunium/synapse-http-antispam
|
||||
matrix_synapse_ext_synapse_http_antispam_enabled: false
|
||||
matrix_synapse_ext_synapse_http_antispam_git_repository_url: "https://github.com/maunium/synapse-http-antispam"
|
||||
# renovate: datasource=github-releases depName=maunium/synapse-http-antispam
|
||||
matrix_synapse_ext_synapse_http_antispam_git_version: "v0.3.0"
|
||||
# Where Synapse can locate the consumer of the antispam API. Currently
|
||||
# Draupnir is the only consumer of this API that is playbook supported.
|
||||
# But https://github.com/maunium/meowlnir also supports the API.
|
||||
matrix_synapse_ext_synapse_http_antispam_config_base_url: ''
|
||||
# This is a shared secret that is established between the consumer and the
|
||||
# homeserver a lot like how AS authentication is done. This is fully managed
|
||||
# the same way AS authentication is by the playbook.
|
||||
matrix_synapse_ext_synapse_http_antispam_config_authorization: ''
|
||||
# This controls what callbacks are activated. This list is fully dependent on what consumer is in play.
|
||||
# And what capabilities said consumer should or shouldn't have. There are also performance implications
|
||||
# to these choices.
|
||||
matrix_synapse_ext_synapse_http_antispam_config_enabled_callbacks: []
|
||||
# Controls if a loss of connectivity to the consumer results in fail open or closed.
|
||||
# As in if failure results in events getting flagged automatically as spam or not.
|
||||
matrix_synapse_ext_synapse_http_antispam_config_fail_open: {}
|
||||
# Controls if the checking is blocking or not. This allows the homeserver to skip waiting for a consumer response.
|
||||
matrix_synapse_ext_synapse_http_antispam_config_async: {}
|
||||
# Actual configuration passed to the synapse-http-antispam module
|
||||
matrix_synapse_ext_synapse_http_antispam_config: "{{ matrix_synapse_ext_synapse_http_antispam_config_yaml | from_yaml }}"
|
||||
matrix_synapse_ext_synapse_http_antispam_config_yaml: |
|
||||
base_url: {{ matrix_synapse_ext_synapse_http_antispam_config_base_url | to_json }}
|
||||
authorization: {{ matrix_synapse_ext_synapse_http_antispam_config_authorization | to_json }}
|
||||
enabled_callbacks: {{ matrix_synapse_ext_synapse_http_antispam_config_enabled_callbacks | to_json }}
|
||||
fail_open: {{ matrix_synapse_ext_synapse_http_antispam_config_fail_open | to_json }}
|
||||
async: {{ matrix_synapse_ext_synapse_http_antispam_config_async | to_json }}
|
||||
|
||||
# Enable this to activate the E2EE disabling Synapse module.
|
||||
# See: https://github.com/digitalentity/matrix_encryption_disabler
|
||||
matrix_synapse_ext_encryption_disabler_enabled: false
|
||||
|
@ -66,6 +66,19 @@
|
||||
- when: matrix_synapse_ext_spam_checker_mjolnir_antispam_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/ext/mjolnir-antispam/setup_install.yml"
|
||||
|
||||
# synapse-http-antispam
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-synapse
|
||||
- install-all
|
||||
- install-synapse
|
||||
block:
|
||||
- when: matrix_synapse_ext_synapse_http_antispam_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/ext/synapse-http-antispam/validate_config.yml"
|
||||
|
||||
- when: matrix_synapse_ext_synapse_http_antispam_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/ext/synapse-http-antispam/setup_install.yml"
|
||||
|
||||
# s3-storage-provider
|
||||
- tags:
|
||||
- setup-all
|
||||
|
@ -0,0 +1,37 @@
|
||||
# SPDX-FileCopyrightText: 2025 MDAD project contributors
|
||||
# SPDX-FileCopyrightText: 2025 Catalan Lover <catalanlover@protonmail.com>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
|
||||
- name: Ensure git installed
|
||||
ansible.builtin.package:
|
||||
name: git
|
||||
state: present
|
||||
|
||||
- name: Clone synapse-http-antispam git repository
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_synapse_ext_synapse_http_antispam_git_repository_url }}"
|
||||
version: "{{ matrix_synapse_ext_synapse_http_antispam_git_version }}"
|
||||
dest: "{{ matrix_synapse_ext_path }}/synapse-http-antispam"
|
||||
become: true
|
||||
become_user: "{{ matrix_synapse_username }}"
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_synapse_modules: >
|
||||
{{
|
||||
matrix_synapse_modules | default([])
|
||||
+
|
||||
[{
|
||||
"module": "synapse_http_antispam.HTTPAntispam",
|
||||
"config": matrix_synapse_ext_synapse_http_antispam_config,
|
||||
}]
|
||||
}}
|
||||
|
||||
matrix_synapse_container_extra_arguments: >
|
||||
{{
|
||||
matrix_synapse_container_extra_arguments | default([])
|
||||
+
|
||||
["--mount type=bind,src={{ matrix_synapse_ext_path }}/synapse-http-antispam/synapse_http_antispam.py,dst={{ matrix_synapse_in_container_python_packages_path }}/synapse_http_antispam.py,ro"]
|
||||
}}
|
@ -0,0 +1,11 @@
|
||||
# SPDX-FileCopyrightText: 2025 MDAD project contributors
|
||||
# SPDX-FileCopyrightText: 2025 Catalan Lover <catalanlover@protonmail.com>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
|
||||
- name: Ensure synapse-http-antispam doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_synapse_ext_path }}/synapse-http-antispam"
|
||||
state: absent
|
@ -0,0 +1,21 @@
|
||||
# SPDX-FileCopyrightText: 2025 MDAD project contributors
|
||||
# SPDX-FileCopyrightText: 2025 Catalan Lover <catalanlover@protonmail.com>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
- name: Fail if required synapse-http-antispam settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`) for using synapse-http-antispam.
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- "matrix_synapse_ext_synapse_http_antispam_enabled"
|
||||
- "matrix_synapse_ext_synapse_http_antispam_config_base_url"
|
||||
- "matrix_synapse_ext_synapse_http_antispam_config_authorization"
|
||||
|
||||
- name: Fail if required matrix_synapse_ext_synapse_http_antispam_config_base_url looks invalid
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
`matrix_synapse_ext_synapse_http_antispam_config_base_url` needs to look like a URL (`http://` or `https://` prefix).
|
||||
when: "not matrix_synapse_ext_synapse_http_antispam_config_base_url.startswith('http')"
|
Reference in New Issue
Block a user