Skip to content

Commit 194bb42

Browse files
spantaleevvenimus
authored andcommitted
Add variables for controlling the native auto-accept-invites Synapse feature
Related to element-hq/synapse#17147
1 parent 3de8aa0 commit 194bb42

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

docs/configuring-playbook-synapse-auto-accept-invite.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,43 @@ The playbook can install and configure [synapse-auto-invite-accept](https://gith
55
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.
66
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.
77

8-
If you decide that you'd like to let this playbook install it for you, you need a configuration like this:
8+
**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.
9+
10+
11+
## Configuration
12+
13+
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:
914

1015
```yaml
1116
matrix_synapse_ext_synapse_auto_accept_invite_enabled: true
1217

1318
matrix_synapse_ext_synapse_auto_accept_invite_accept_invites_only_direct_messages: true
1419
```
1520
16-
## Synapse worker deployments
21+
### Synapse worker deployments
1722
18-
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:
23+
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:
1924

2025
```yaml
2126
matrix_synapse_ext_synapse_auto_accept_invite_worker_to_run_on: 'matrix-synapse-worker-generic-0'
2227
```
2328

24-
There might be an [issue with federation](https://github.com/matrix-org/synapse-auto-accept-invite/issues/18).
29+
There might be an [issue with federation](https://github.com/matrix-org/synapse-auto-accept-invite/issues/18).
30+
31+
32+
## Native alternative
33+
34+
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.
35+
36+
Here's example configuration for using the **native** Synapse feature:
37+
38+
```yml
39+
matrix_synapse_auto_accept_invites_enabled: true
40+
41+
# Default settings below. Uncomment and adjust if necessary.
42+
# matrix_synapse_auto_accept_invites_only_for_direct_messages: false
43+
# matrix_synapse_auto_accept_invites_only_from_local_users: false
44+
45+
# If workers are enabled, you may delegate usage to a specific worker.
46+
# matrix_synapse_auto_accept_invites_worker_to_run_on: 'matrix-synapse-worker-generic-0'
47+
```

roles/custom/matrix-synapse/defaults/main.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,27 @@ matrix_synapse_auto_join_rooms: []
543543
# automatically if they don't already exist.
544544
matrix_synapse_autocreate_auto_join_rooms: true
545545

546+
# Controls whether room invites will be accepted on behalf of users.
547+
# See: https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#auto-accept-invites
548+
# This should not be used together with the `synapse_auto_accept_invite` module (see `matrix_synapse_ext_synapse_auto_accept_invite_enabled`).
549+
# Also see:
550+
# - `matrix_synapse_auto_accept_invites_only_for_direct_messages`
551+
# - `matrix_synapse_auto_accept_invites_only_from_local_users`
552+
# - `matrix_synapse_auto_accept_invites_worker_to_run_on`
553+
matrix_synapse_auto_accept_invites_enabled: false
554+
555+
# Controls whether auto-invite acceptance should only be done for direct messages.
556+
# Related to: `matrix_synapse_auto_accept_invites_enabled`
557+
matrix_synapse_auto_accept_invites_only_for_direct_messages: false
558+
559+
# Controls whether auto-invite acceptance should only be done when the invitatio nis coming from a local user.
560+
# Related to: `matrix_synapse_auto_accept_invites_enabled`
561+
matrix_synapse_auto_accept_invites_only_from_local_users: false
562+
563+
# 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).
564+
# Related to: `matrix_synapse_auto_accept_invites_enabled`
565+
matrix_synapse_auto_accept_invites_worker_to_run_on: null
566+
546567
# Controls whether password authentication is allowed
547568
# It may be useful when you've configured OAuth, SAML or CAS and want authentication
548569
# to happen only through them
@@ -1228,6 +1249,10 @@ matrix_synapse_ext_synapse_s3_storage_provider_update_db_day_count: 0
12281249
matrix_synapse_ext_synapse_s3_storage_provider_periodic_migration_schedule: '*-*-* 05:00:00'
12291250

12301251
# Synapse module to automatically accept room invites.
1252+
#
1253+
# Since Synapse v1.109.0 (https://github.com/element-hq/synapse/pull/17147),
1254+
# this functionality has been merged into Synapse. See `matrix_synapse_auto_accept_invites_enabled`.
1255+
#
12311256
# See: https://github.com/matrix-org/synapse-auto-accept-invite
12321257
# Installing it requires building a customized Docker image for Synapse (see `matrix_synapse_container_image_customizations_enabled`).
12331258
# Enabling this will enable customizations and inject the appropriate Dockerfile clauses for installing synapse-auto-accept-invite.

roles/custom/matrix-synapse/tasks/validate_config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,15 @@
121121
when: "matrix_synapse_container_image_customizations_templates_git_repository_keyscan_enabled | bool and vars[item] == ''"
122122
with_items:
123123
- matrix_synapse_container_image_customizations_templates_git_repository_keyscan_hostname
124+
125+
126+
- name: Fail when auto-accept-invite enabled as a native feature and a module at the same time
127+
ansible.builtin.fail:
128+
msg: >-
129+
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`).
130+
This is unnecessary, since they both do the same and the native feature is built on top of the 3rd party module anyway.
131+
Enabling both at the same time will lead to issues.
132+
We recommend leaving `matrix_synapse_auto_accept_invites_enabled` in your configuration and removing `matrix_synapse_ext_synapse_auto_accept_invite_enabled`.
133+
when:
134+
- matrix_synapse_auto_accept_invites_enabled
135+
- matrix_synapse_ext_synapse_auto_accept_invite_enabled

roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,12 @@ autocreate_auto_join_rooms: {{ matrix_synapse_autocreate_auto_join_rooms|to_json
15501550
#
15511551
#auto_join_rooms_for_guests: false
15521552

1553+
auto_accept_invites:
1554+
enabled: {{ matrix_synapse_auto_accept_invites_enabled | to_json }}
1555+
only_for_direct_messages: {{ matrix_synapse_auto_accept_invites_only_for_direct_messages | to_json }}
1556+
only_from_local_users: {{ matrix_synapse_auto_accept_invites_only_from_local_users | to_json }}
1557+
worker_to_run_on: {{ matrix_synapse_auto_accept_invites_worker_to_run_on | to_json }}
1558+
15531559
# Whether to inhibit errors raised when registering a new account if the user ID
15541560
# already exists. If turned on, that requests to /register/available will always
15551561
# show a user ID as available, and Synapse won't raise an error when starting
@@ -1565,7 +1571,7 @@ autocreate_auto_join_rooms: {{ matrix_synapse_autocreate_auto_join_rooms|to_json
15651571

15661572
# Enable collection and rendering of performance metrics
15671573
#
1568-
enable_metrics: {{ matrix_synapse_metrics_enabled|to_json }}
1574+
enable_metrics: {{ matrix_synapse_metrics_enabled|to_json }}
15691575

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

0 commit comments

Comments
 (0)