From ef90ee94954d03d840b50818142af1ea70f81b33 Mon Sep 17 00:00:00 2001 From: hagene Date: Thu, 27 Jun 2024 14:51:06 +0200 Subject: [PATCH 1/2] Allow configuring synapse `auto_join_mxid_localpart` `auto_join_mxid_localpart` defines the local part of the user id which is used to create auto-join rooms. The variable needs to be set to invite new users to any auto-join rooms which are set to invite-only. --- roles/custom/matrix-synapse/defaults/main.yml | 6 ++++++ .../matrix-synapse/templates/synapse/homeserver.yaml.j2 | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/roles/custom/matrix-synapse/defaults/main.yml b/roles/custom/matrix-synapse/defaults/main.yml index 4c8465077..e31845741 100644 --- a/roles/custom/matrix-synapse/defaults/main.yml +++ b/roles/custom/matrix-synapse/defaults/main.yml @@ -537,12 +537,18 @@ matrix_synapse_account_threepid_delegates_msisdn: '' # Users who register on this homeserver will automatically be joined to these rooms. # Rooms are to be specified using addresses (e.g. `#address:example.com`) +# If any auto-join rooms are invite-only, you need to define `matrix_synapse_auto_join_mxid_localpart`. matrix_synapse_auto_join_rooms: [] # Controls whether auto-join rooms (`matrix_synapse_auto_join_rooms`) are to be created # automatically if they don't already exist. matrix_synapse_autocreate_auto_join_rooms: true +# The local part of the user id which is used to create auto-join rooms if `matrix_synapse_autocreate_auto_join_rooms` is true. +# Defaults to the initial user account that registers. +# The user id is also used to invite new users to any auto-join rooms which are set to invite-only. +matrix_synapse_auto_join_mxid_localpart: '' + # 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`). diff --git a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 index dc9970ec9..f8e77930d 100644 --- a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 +++ b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 @@ -1541,7 +1541,9 @@ autocreate_auto_join_rooms: {{ matrix_synapse_autocreate_auto_join_rooms|to_json # Note that, if the room already exists, this user must be joined and # have the appropriate permissions to invite new members. # -#auto_join_mxid_localpart: system +{% if matrix_synapse_auto_join_mxid_localpart %} +auto_join_mxid_localpart: {{ matrix_synapse_auto_join_mxid_localpart }} +{% endif %} # When auto_join_rooms is specified, setting this flag to false prevents # guest accounts from being automatically joined to the rooms. From 4aa3345db0c6a1a13384e29f773787941f1412f5 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 27 Jun 2024 21:35:56 +0300 Subject: [PATCH 2/2] Simplify auto_join_mxid_localpart population --- .../matrix-synapse/templates/synapse/homeserver.yaml.j2 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 index f8e77930d..48bacc4f6 100644 --- a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 +++ b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 @@ -1541,9 +1541,7 @@ autocreate_auto_join_rooms: {{ matrix_synapse_autocreate_auto_join_rooms|to_json # Note that, if the room already exists, this user must be joined and # have the appropriate permissions to invite new members. # -{% if matrix_synapse_auto_join_mxid_localpart %} -auto_join_mxid_localpart: {{ matrix_synapse_auto_join_mxid_localpart }} -{% endif %} +auto_join_mxid_localpart: {{ matrix_synapse_auto_join_mxid_localpart | to_json }} # When auto_join_rooms is specified, setting this flag to false prevents # guest accounts from being automatically joined to the rooms.