Skip to content

Commit

Permalink
Add variables for controlling the native auto-accept-invites Synapse …
Browse files Browse the repository at this point in the history
…feature

Related to element-hq/synapse#17147
  • Loading branch information
spantaleev committed Jun 18, 2024
1 parent 9af4b49 commit 09d9db5
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
31 changes: 27 additions & 4 deletions docs/configuring-playbook-synapse-auto-accept-invite.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,43 @@ The playbook can install and configure [synapse-auto-invite-accept](https://gith
See that project's [documentation](https://github.com/matrix-org/synapse-auto-accept-invite) to learn what it does and why it might be useful to you.
In short, it automatically accepts room invites. You can specify that only 1:1 room invites are auto-accepted. Defaults to false if not specified.

If you decide that you'd like to let this playbook install it for you, you need a configuration like this:
**NOTE**: Synapse [v1.109.0](https://github.com/element-hq/synapse/releases/tag/v1.109.0), the same feature [has been merged](https://github.com/element-hq/synapse/pull/17147) into Synapse (see the [Native alternative](#native-alternative) section below). You'd better use the native feature, instead of the [synapse-auto-invite-accept](https://github.com/matrix-org/synapse-auto-accept-invite) 3rd party module.


## Configuration

If you decide that you'd like to let this playbook install the [synapse-auto-invite-accept](https://github.com/matrix-org/synapse-auto-accept-invite module for you, you need a configuration like this:

```yaml
matrix_synapse_ext_synapse_auto_accept_invite_enabled: true

matrix_synapse_ext_synapse_auto_accept_invite_accept_invites_only_direct_messages: true
```
## Synapse worker deployments
### Synapse worker deployments
In a [workerized Synapse deployment](https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/c9a842147e09647c355799ca024d65a5de66b099/docs/configuring-playbook-synapse.md#load-balancing-with-workers) it is possible to run this module on a worker to reduce the load on the main process (Default is 'null'). For example add this to your configuration:
In a [workerized Synapse deployment](https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/c9a842147e09647c355799ca024d65a5de66b099/docs/configuring-playbook-synapse.md#load-balancing-with-workers) it is possible to run this module on a worker to reduce the load on the main process (Default is `null`). For example, add this to your configuration:

```yaml
matrix_synapse_ext_synapse_auto_accept_invite_worker_to_run_on: 'matrix-synapse-worker-generic-0'
```

There might be an [issue with federation](https://github.com/matrix-org/synapse-auto-accept-invite/issues/18).
There might be an [issue with federation](https://github.com/matrix-org/synapse-auto-accept-invite/issues/18).


## Native alternative

Since Synapse [v1.109.0](https://github.com/element-hq/synapse/releases/tag/v1.109.0), the functionality provided by the [synapse-auto-invite-accept](https://github.com/matrix-org/synapse-auto-accept-invite) 3rd party module [has been made](https://github.com/element-hq/synapse/pull/17147) part of Synapse.

Here's example configuration for using the **native** Synapse feature:

```yml
matrix_synapse_auto_accept_invites_enabled: true
# Default settings below. Uncomment and adjust if necessary.
# matrix_synapse_auto_accept_invites_only_for_direct_messages: false
# matrix_synapse_auto_accept_invites_only_from_local_users: false
# If workers are enabled, you may delegate usage to a specific worker.
# matrix_synapse_auto_accept_invites_worker_to_run_on: 'matrix-synapse-worker-generic-0'
```
25 changes: 25 additions & 0 deletions roles/custom/matrix-synapse/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,27 @@ matrix_synapse_auto_join_rooms: []
# automatically if they don't already exist.
matrix_synapse_autocreate_auto_join_rooms: true

# Controls whether room invites will be accepted on behalf of users.
# See: https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#auto-accept-invites
# This should not be used together with the `synapse_auto_accept_invite` module (see `matrix_synapse_ext_synapse_auto_accept_invite_enabled`).
# Also see:
# - `matrix_synapse_auto_accept_invites_only_for_direct_messages`
# - `matrix_synapse_auto_accept_invites_only_from_local_users`
# - `matrix_synapse_auto_accept_invites_worker_to_run_on`
matrix_synapse_auto_accept_invites_enabled: false

# Controls whether auto-invite acceptance should only be done for direct messages.
# Related to: `matrix_synapse_auto_accept_invites_enabled`
matrix_synapse_auto_accept_invites_only_for_direct_messages: false

# Controls whether auto-invite acceptance should only be done when the invitatio nis coming from a local user.
# Related to: `matrix_synapse_auto_accept_invites_enabled`
matrix_synapse_auto_accept_invites_only_from_local_users: false

# When Synapse workers enabled it is possible (but not required) to assign a worker to run the auto-accept-invites feature on (null = main process).
# Related to: `matrix_synapse_auto_accept_invites_enabled`
matrix_synapse_auto_accept_invites_worker_to_run_on: null

# Controls whether password authentication is allowed
# It may be useful when you've configured OAuth, SAML or CAS and want authentication
# to happen only through them
Expand Down Expand Up @@ -1228,6 +1249,10 @@ matrix_synapse_ext_synapse_s3_storage_provider_update_db_day_count: 0
matrix_synapse_ext_synapse_s3_storage_provider_periodic_migration_schedule: '*-*-* 05:00:00'

# Synapse module to automatically accept room invites.
#
# Since Synapse v1.109.0 (https://github.com/element-hq/synapse/pull/17147),
# this functionality has been merged into Synapse. See `matrix_synapse_auto_accept_invites_enabled`.
#
# See: https://github.com/matrix-org/synapse-auto-accept-invite
# Installing it requires building a customized Docker image for Synapse (see `matrix_synapse_container_image_customizations_enabled`).
# Enabling this will enable customizations and inject the appropriate Dockerfile clauses for installing synapse-auto-accept-invite.
Expand Down
12 changes: 12 additions & 0 deletions roles/custom/matrix-synapse/tasks/validate_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,15 @@
when: "matrix_synapse_container_image_customizations_templates_git_repository_keyscan_enabled | bool and vars[item] == ''"
with_items:
- matrix_synapse_container_image_customizations_templates_git_repository_keyscan_hostname


- name: Fail when auto-accept-invite enabled as a native feature and a module at the same time
ansible.builtin.fail:
msg: >-
Your configuration enables the auto-accept invites feature both as a native Synapse feature (`matrix_synapse_auto_accept_invites_enabled`) and a 3rd party module (`matrix_synapse_ext_synapse_auto_accept_invite_enabled`).
This is unnecessary, since they both do the same and the native feature is built on top of the 3rd party module anyway.
Enabling both at the same time will lead to issues.
We recommend leaving `matrix_synapse_auto_accept_invites_enabled` in your configuration and removing `matrix_synapse_ext_synapse_auto_accept_invite_enabled`.
when:
- matrix_synapse_auto_accept_invites_enabled
- matrix_synapse_ext_synapse_auto_accept_invite_enabled
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,12 @@ autocreate_auto_join_rooms: {{ matrix_synapse_autocreate_auto_join_rooms|to_json
#
#auto_join_rooms_for_guests: false

auto_accept_invites:
enabled: {{ matrix_synapse_auto_accept_invites_enabled | to_json }}
only_for_direct_messages: {{ matrix_synapse_auto_accept_invites_only_for_direct_messages | to_json }}
only_from_local_users: {{ matrix_synapse_auto_accept_invites_only_from_local_users | to_json }}
worker_to_run_on: {{ matrix_synapse_auto_accept_invites_worker_to_run_on | to_json }}

# Whether to inhibit errors raised when registering a new account if the user ID
# already exists. If turned on, that requests to /register/available will always
# show a user ID as available, and Synapse won't raise an error when starting
Expand All @@ -1565,7 +1571,7 @@ autocreate_auto_join_rooms: {{ matrix_synapse_autocreate_auto_join_rooms|to_json

# Enable collection and rendering of performance metrics
#
enable_metrics: {{ matrix_synapse_metrics_enabled|to_json }}
enable_metrics: {{ matrix_synapse_metrics_enabled|to_json }}

# Enable sentry integration
# NOTE: While attempts are made to ensure that the logs don't contain
Expand Down

0 comments on commit 09d9db5

Please sign in to comment.