From 394fdca0660714f09406f6c9b8649f2495318614 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 21 Nov 2024 18:54:29 +0200 Subject: [PATCH] Relocate org.matrix.msc4143.rtc_foci setup to /.well-known/matrix/client to matrix-static-files instead of ugly patching --- group_vars/matrix_servers | 8 +++++++ .../matrix-element-call/tasks/install.yml | 8 +------ .../tasks/update_well_known_client.yml | 21 ------------------- .../matrix-livekit-server/defaults/main.yml | 1 + .../matrix-livekit-server/vars/main.yml | 1 + .../matrix-static-files/defaults/main.yml | 10 +++++++++ .../public/.well-known/matrix/client.j2 | 3 +++ 7 files changed, 24 insertions(+), 28 deletions(-) delete mode 100644 roles/custom/matrix-element-call/tasks/update_well_known_client.yml create mode 100644 roles/custom/matrix-livekit-server/vars/main.yml diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index d88305467..dad4e29d4 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -5912,6 +5912,14 @@ matrix_static_files_file_matrix_client_property_m_tile_server_map_style_url: "{{ # See: https://github.com/etkecc/synapse-admin/pull/126 matrix_static_files_file_matrix_client_property_cc_etke_synapse_admin_auto: "{{ matrix_synapse_admin_configuration if matrix_homeserver_implementation == 'synapse' else {} }}" +matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_enabled: "{{ matrix_element_call_enabled }}" +matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_auto: |- + {{ + ( + [{'type': 'livekit', 'livekit_service_url': matrix_jwt_service_url}] if matrix_jwt_service_enabled else [] + ) + }} + matrix_static_files_file_matrix_server_property_m_server: "{{ matrix_server_fqn_matrix_federation }}:{{ matrix_federation_public_port }}" matrix_static_files_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}" diff --git a/roles/custom/matrix-element-call/tasks/install.yml b/roles/custom/matrix-element-call/tasks/install.yml index ca6b5903b..f11d002e3 100644 --- a/roles/custom/matrix-element-call/tasks/install.yml +++ b/roles/custom/matrix-element-call/tasks/install.yml @@ -78,12 +78,6 @@ group: "{{ matrix_user_groupname }}" when: matrix_element_call_enabled | bool -# Update the well-known client file for Element Call (adding RTC FOCI) -- name: Update the well-known client file for Element Call - ansible.builtin.include_tasks: "tasks/update_well_known_client.yml" - when: matrix_element_call_enabled | bool - - # Create .well-known/element/element.json for Element Call - name: Create the well-known element.json file ansible.builtin.template: @@ -96,4 +90,4 @@ # Update Element Web config.json with Element Call settings - name: Update Element Web config.json ansible.builtin.include_tasks: "tasks/update_element_web_config.yml" - when: matrix_element_call_enabled | bool \ No newline at end of file + when: matrix_element_call_enabled | bool diff --git a/roles/custom/matrix-element-call/tasks/update_well_known_client.yml b/roles/custom/matrix-element-call/tasks/update_well_known_client.yml deleted file mode 100644 index bcf3f726b..000000000 --- a/roles/custom/matrix-element-call/tasks/update_well_known_client.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Read the existing well-known client file - ansible.builtin.slurp: - path: "{{ matrix_base_data_path }}/static-files/public/.well-known/matrix/client" - register: client_file_content - -- name: Load the existing JSON content - ansible.builtin.set_fact: - client_json: "{{ client_file_content['content'] | b64decode | from_json }}" - -- name: Update the existing well-known client file for Element Call (RTC FOCI) - ansible.builtin.set_fact: - updated_client_json: "{{ client_json | combine({'org.matrix.msc4143.rtc_foci': [{'type': 'livekit', 'livekit_service_url': matrix_jwt_service_url}]}, recursive=True) }}" - -- name: Write the updated well-known client file - ansible.builtin.copy: - content: "{{ updated_client_json | to_nice_json }}" - dest: "{{ matrix_base_data_path }}/static-files/public/.well-known/matrix/client" - mode: '0644' - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_groupname }}" \ No newline at end of file diff --git a/roles/custom/matrix-livekit-server/defaults/main.yml b/roles/custom/matrix-livekit-server/defaults/main.yml index cd11a6732..c52e91736 100644 --- a/roles/custom/matrix-livekit-server/defaults/main.yml +++ b/roles/custom/matrix-livekit-server/defaults/main.yml @@ -15,6 +15,7 @@ livekit_server_config_path: "{{ livekit_server_base_path }}/config" # renovate: datasource=docker depName=livekit/livekit-server livekit_server_version: v1.8.0 +livekit_server_scheme: https livekit_server_hostname: "" livekit_server_path_prefix: / diff --git a/roles/custom/matrix-livekit-server/vars/main.yml b/roles/custom/matrix-livekit-server/vars/main.yml new file mode 100644 index 000000000..e2f8c0ee7 --- /dev/null +++ b/roles/custom/matrix-livekit-server/vars/main.yml @@ -0,0 +1 @@ +livekit_server_public_url: "{{ livekit_server_scheme }}://{{ livekit_server_hostname }}{{ livekit_server_path_prefix }}" diff --git a/roles/custom/matrix-static-files/defaults/main.yml b/roles/custom/matrix-static-files/defaults/main.yml index 7e3abf2f5..06a3af624 100644 --- a/roles/custom/matrix-static-files/defaults/main.yml +++ b/roles/custom/matrix-static-files/defaults/main.yml @@ -203,6 +203,16 @@ matrix_static_files_file_matrix_client_property_cc_etke_synapse_admin: "{{ matri matrix_static_files_file_matrix_client_property_cc_etke_synapse_admin_auto: {} matrix_static_files_file_matrix_client_property_cc_etke_synapse_admin_custom: {} +# Controls whether `org.matrix.msc4143.rtc_foci`-related entries should be added to the client well-known. +# By default, if there are entries in `matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci`, we show them (by enabling this). +matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_enabled: "{{ matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci | default({}) | dict2items | length > 0 }}" + +# Controls the org.matrix.msc4143.rtc_foci property in the /.well-known/matrix/client file. +# See `matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_enabled` +matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci: "{{ matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_auto | combine(matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_custom, recursive=True) }}" +matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_auto: {} +matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_custom: {} + # Default /.well-known/matrix/client configuration template which covers the generic use case. # You can customize it by controlling the various variables inside it. # diff --git a/roles/custom/matrix-static-files/templates/public/.well-known/matrix/client.j2 b/roles/custom/matrix-static-files/templates/public/.well-known/matrix/client.j2 index 86882893a..600e8f4c7 100644 --- a/roles/custom/matrix-static-files/templates/public/.well-known/matrix/client.j2 +++ b/roles/custom/matrix-static-files/templates/public/.well-known/matrix/client.j2 @@ -57,4 +57,7 @@ {% if matrix_static_files_file_matrix_client_property_cc_etke_synapse_admin_enabled %}, "cc.etke.synapse-admin": {{ matrix_static_files_file_matrix_client_property_cc_etke_synapse_admin | to_json }} {% endif %} + {% if matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_enabled %}, + "org.matrix.msc4143.rtc_foci": {{ matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci | to_json }} + {% endif %} }