From 8494db19a6677135b89809d39cd6e8a9eec04e76 Mon Sep 17 00:00:00 2001 From: hanthor Date: Wed, 12 May 2021 13:10:55 -0400 Subject: [PATCH] Got it to run and register --- group_vars/matrix_servers | 8 ------ .../defaults/main.yml | 26 ++++++++----------- .../tasks/init.yml | 10 +++---- .../tasks/setup_install.yml | 9 ------- .../templates/config.yaml.j2 | 8 +----- .../systemd/matrix-mautrix-wsproxy.service.j2 | 2 -- 6 files changed, 17 insertions(+), 46 deletions(-) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 713688b50..53746c082 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -489,8 +489,6 @@ matrix_mautrix_wsproxy_appservice_token: "{{ matrix_synapse_macaroon_secret_key matrix_mautrix_wsproxy_login_shared_secret: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret if matrix_synapse_ext_password_provider_shared_secret_auth_enabled else '' }}" # Postgres is the default, except if not using `matrix_postgres` (internal postgres) -matrix_mautrix_wsproxy_database_engine: "{{ 'postgres' if matrix_postgres_enabled else 'sqlite' }}" -matrix_mautrix_wsproxy_database_password: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'mauwsproxy.db') | to_uuid }}" ###################################################################### # @@ -1411,12 +1409,6 @@ matrix_postgres_additional_databases: | 'password': matrix_mautrix_whatsapp_database_password, }] if (matrix_mautrix_whatsapp_enabled and matrix_mautrix_whatsapp_database_engine == 'postgres' and matrix_mautrix_whatsapp_database_hostname == 'matrix-postgres') else []) + - ([{ - 'name': matrix_mautrix_wsproxy_database_name, - 'username': matrix_mautrix_wsproxy_database_username, - 'password': matrix_mautrix_wsproxy_database_password, - }] if (matrix_mautrix_wsproxy_enabled and matrix_mautrix_wsproxy_database_engine == 'postgres' and matrix_mautrix_wsproxy_database_hostname == 'matrix-postgres') else []) - + ([{ 'name': matrix_mx_puppet_skype_database_name, 'username': matrix_mx_puppet_skype_database_username, diff --git a/roles/matrix-bridge-mautrix-wsproxy/defaults/main.yml b/roles/matrix-bridge-mautrix-wsproxy/defaults/main.yml index f66e17f8b..3a3b70bcd 100644 --- a/roles/matrix-bridge-mautrix-wsproxy/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-wsproxy/defaults/main.yml @@ -52,23 +52,19 @@ matrix_mautrix_wsproxy_configuration_extension: "{{ matrix_mautrix_wsproxy_confi matrix_mautrix_wsproxy_configuration: "{{ matrix_mautrix_wsproxy_configuration_yaml|from_yaml|combine(matrix_mautrix_wsproxy_configuration_extension, recursive=True) }}" matrix_mautrix_wsproxy_registration_yaml: | - # appservice -> id from the config id: wsproxy - # appservice -> as_token and hs_token from the config - as_token: random string - hs_token: random string - namespaces: - users: - # The localpart here is username_template from the config, but .+ instead of {{.}} - - regex: '@imessage_.+:{{ matrix_mautrix_telegram_homeserver_domain|regex_escape }}$' - exclusive: true - # Localpart here is appservice -> bot -> username from the config - - regex: '@imessagebot:{{ matrix_mautrix_telegram_homeserver_domain|regex_escape }}$' - exclusive: true - # Address that Synapse uses to contact mautrix-wsproxy url: {{ matrix_mautrix_wsproxy_appservice_address }} - # Put a new random string here, it doesn't affect anything else - sender_localpart: random string + as_token: "{{ matrix_mautrix_wsproxy_appservice_token }}" + hs_token: "{{ matrix_mautrix_wsproxy_homeserver_token }}" + # See https://github.com/tulir/mautrix-signal/issues/43 + sender_localpart: _bot_{{ matrix_mautrix_wsproxy_appservice_bot_username }} rate_limited: false + namespaces: + users: + - regex: '^@wsproxy_[0-9]+:{{ matrix_mautrix_wsproxy_homeserver_domain|regex_escape }}$' + exclusive: true + - exclusive: true + regex: '^@{{ matrix_mautrix_wsproxy_appservice_bot_username|regex_escape }}:{{ matrix_mautrix_wsproxy_homeserver_domain|regex_escape }}$' + de.sorunome.msc2409.push_ephemeral: true matrix_mautrix_wsproxy_registration: "{{ matrix_mautrix_wsproxy_registration_yaml|from_yaml }}" diff --git a/roles/matrix-bridge-mautrix-wsproxy/tasks/init.yml b/roles/matrix-bridge-mautrix-wsproxy/tasks/init.yml index f320bc743..3f37d7045 100644 --- a/roles/matrix-bridge-mautrix-wsproxy/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-wsproxy/tasks/init.yml @@ -1,16 +1,16 @@ - set_fact: - matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-whatsapp.service'] }}" - when: matrix_mautrix_whatsapp_enabled|bool + matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-wsproxy.service'] }}" + when: matrix_mautrix_wsproxy_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. - set_fact: matrix_synapse_container_extra_arguments: > {{ matrix_synapse_container_extra_arguments|default([]) }} + - ["--mount type=bind,src={{ matrix_mautrix_whatsapp_config_path }}/registration.yaml,dst=/matrix-mautrix-whatsapp-registration.yaml,ro"] + ["--mount type=bind,src={{ matrix_mautrix_wsproxy_config_path }}/registration.yaml,dst=/matrix-mautrix-wsproxy-registration.yaml,ro"] matrix_synapse_app_service_config_files: > {{ matrix_synapse_app_service_config_files|default([]) }} + - {{ ["/matrix-mautrix-whatsapp-registration.yaml"] }} - when: matrix_mautrix_whatsapp_enabled|bool + {{ ["/matrix-mautrix-wsproxy-registration.yaml"] }} + when: matrix_mautrix_wsproxy_enabled|bool diff --git a/roles/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml index 77f400479..c1488b75d 100644 --- a/roles/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml +++ b/roles/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml @@ -28,21 +28,12 @@ with_items: - "{{ matrix_mautrix_wsproxy_base_path }}" - "{{ matrix_mautrix_wsproxy_config_path }}" - - "{{ matrix_mautrix_wsproxy_data_path }}" - name: Check if an old matrix state file exists stat: path: "{{ matrix_mautrix_wsproxy_base_path }}/mx-state.json" register: matrix_mautrix_wsproxy_stat_mx_state -- name: (Data relocation) Move mautrix-wsproxy database file to ./data directory - command: "mv {{ matrix_mautrix_wsproxy_base_path }}/mautrix-wsproxy.db {{ matrix_mautrix_wsproxy_data_path }}/mautrix-wsproxy.db" - when: "matrix_mautrix_wsproxy_stat_database.stat.exists" - -- name: (Data relocation) Move mautrix-wsproxy mx-state file to ./data directory - command: "mv {{ matrix_mautrix_wsproxy_base_path }}/mx-state.json {{ matrix_mautrix_wsproxy_data_path }}/mx-state.json" - when: "matrix_mautrix_wsproxy_stat_mx_state.stat.exists" - - name: Ensure mautrix-wsproxy config.yaml installed copy: content: "{{ matrix_mautrix_wsproxy_configuration|to_nice_yaml }}" diff --git a/roles/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 b/roles/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 index a486278d8..b1332f208 100644 --- a/roles/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 +++ b/roles/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 @@ -24,9 +24,6 @@ appservice: # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s max_body_size: 1 - # The full URI to the database. Only Postgres is currently supported. - database: {{ matrix_mautrix_wsproxy_database_connection_string }} - # Provisioning API part of the web server for automated portal creation and fetching information. # Used by things like mautrix-manager (https://github.com/tulir/mautrix-manager). provisioning: @@ -44,7 +41,7 @@ appservice: bot_username: {{ matrix_mautrix_wsproxy_appservice_bot_username|to_json }} # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty # to leave display name/avatar as-is. - bot_displayname: Android Messages bridge bot + bot_displayname: iMessage bridge bot bot_avatar: mxc://maunium.net/VuvevQiMRlOxuBVMBNEZZrxi # Community ID for bridged users (changes registration file) and rooms. @@ -131,9 +128,6 @@ bridge: # The prefix for commands. Only required in non-management rooms. command_prefix: "!im" - # This bridge only supports a single user - user: "{{ matrix_mautrix_wsproxy_bridge_user }}" - logging: # The directory for log files. Will be created if not found. directory: ./logs diff --git a/roles/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 b/roles/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 index 7b31cd3f8..b1b376acf 100644 --- a/roles/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 +++ b/roles/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 @@ -25,8 +25,6 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-mautrix-wsprox --cap-drop=ALL \ --network={{ matrix_docker_network }} \ -v {{ matrix_mautrix_wsproxy_config_path }}:/config:z \ - -v {{ matrix_mautrix_wsproxy_data_path }}:/data:z \ - --workdir=/data \ {% for arg in matrix_mautrix_wsproxy_container_extra_arguments %} {{ arg }} \ {% endfor %}