spantaleev / matrix-docker-ansible-deploy

🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker
GNU Affero General Public License v3.0
4.9k stars 1.04k forks source link

Issues setting up mautrix bridges with dendrite #1611

Open nickypro opened 2 years ago

nickypro commented 2 years ago

Hi All, there is a small issue when setting up the mautrix bridges with dendrite there is a couple of issues ( tested only with mautrix-facebook and mautrix-whatsapp so far ). I don't have any experience with ansible, but was able to find out how to modify the config files to work. I may fix this when I have time though if anyone else has experience with ansible they could probably do it quicker.

  1. the registration.yaml files are not available in the matrix-dendrite container as far as I can see. ( I worked around this by hard linking the registration files to /matrix/dendrite/config). It seems they are usually attached individually by as a docker volume in synapse.
  2. in '/matrix/dendrite/config/dendrite.yaml' there is no entries for the bridge registration files in config-files. it has an empty list [] value, but mine now looks like this ( in synapse there is no /data part ):
    app_service_api:
    config_files: 
    - /data/matrix-mautrix-facebook-registration.yaml
    - /data/matrix-mautrix-whatsapp-registration.yaml
  3. dendrite does not ignore options that it doesn't understand, so I had to remove the de.sorunome.msc2409.push_ephemeral: true option in the registration files

The bridges seem to work so far with these parameters, though I haven't done much testing yet. I think these configurations should work with the ansible configuration as well.

spantaleev commented 2 years ago

Thanks for confirming that these bridges work!

Right now, bridges use an init task (roles/SOME_BRIDGE/tasks/init.yml) to dynamically inject themselves into Synapse configuration and volumes when the given bridge is enabled.

Example: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/e0df99a7de66e0fec8ba131605f3a39e60c51cd4/roles/matrix-bridge-mautrix-facebook/tasks/init.yml#L13-L24


We either need to copy/paste these tasks and do the same for Dendrite after adjusting some variable names:

.. or we should make roles inject themselves into more generic variables (e.g. matrix_homeserver_container_extra_arguments or matrix_homeserver_additional_volumes; matrix_homeserver_app_service_config_files). These variables can later get passed along to all homeserver implementations.

This 2nd way of doing things will let us more easily add new homeserver implementations, without having to copy/paste init.yaml tasks again.. However, I'm not sure if the "appservice registration" YAML thing is spec-ed and compatible between homeserver implementations.


Looks like Dendrite handles appservice configuration files differently. We should likely report this upstream at the Dendrite repository, so they can make things easier for people. Alternatively (or additionally), we can also add some if statements to the appservice configuration to make it not add these incompatible options for other homeserver implementations: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/e0df99a7de66e0fec8ba131605f3a39e60c51cd4/roles/matrix-bridge-mautrix-facebook/defaults/main.yml#L99-L113

Example:

{% if matrix_homeserver_implementation == 'synapse' %}
de.sorunome.msc2409.push_ephemeral: true
{% endif %}

(we should be careful with indentation here)

nickypro commented 2 years ago

Looks like the last issue is mentioned here: https://github.com/matrix-org/dendrite/issues/1567

not sure if they have a decision on how best to handle unknown options other than to give an error, so likely the if option would be better

edgar-vincent commented 2 years ago

FYI, https://github.com/matrix-org/dendrite/issues/1567 has just been closed.

Kab1r commented 2 years ago

Yep, this should be fixed with the next release of dendrite!

madprogramer commented 2 years ago

bump! @spantaleev 's solution of copy-pasting variables works on the latest version. At least for WhatsApp.

- ansible.builtin.set_fact:
    matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-whatsapp.service'] }}"
  when: matrix_mautrix_whatsapp_enabled | bool

- ansible.builtin.set_fact:
    # If the matrix-synapse role is not used, these variables may not exist.
    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"]
      }}

    matrix_synapse_app_service_config_files: >
      {{
        matrix_synapse_app_service_config_files | default([])
        +
        ["/matrix-mautrix-whatsapp-registration.yaml"]
      }}

    # If the matrix-dendrite role is not used, these variables may not exist.
    matrix_dendrite_container_extra_arguments: >
      {{
        matrix_dendrite_container_extra_arguments | default([])
        +
        ["--mount type=bind,src={{ matrix_mautrix_whatsapp_config_path }}/registration.yaml,dst=/matrix-mautrix-whatsapp-registration.yaml,ro"]
      }}

    matrix_dendrite_app_service_config_files: >
      {{
        matrix_dendrite_app_service_config_files | default([])
        +
        ["/matrix-mautrix-whatsapp-registration.yaml"]
      }}

  when: matrix_mautrix_whatsapp_enabled | bool

Maybe I should PR this?

shalzz commented 2 years ago

Has anyone tried setting up other mautrix bridges with the latest dendrite release?

Maybe we can go ahead with setting up the generic variables to avoid duplication until we come across a homeserver implementation that breaks with the common values?

madprogramer commented 2 years ago

PRing support for Facebook, Telegram, WhatsApp and Discord (without DMs) @shalzz https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/2044

spantaleev commented 2 years ago

2044 has been superseded by #2045 and it seems like it should land soon.

ibeckermayer commented 1 year ago

Is bridging still generally an issue with Dendrite? I'm thinking of switching over to Dendrite to save memory resources, but don't want to go through the trouble if the bridges aren't very reliable yet.

Kab1r commented 1 year ago

I have had some bridges work with dendrite. Mautrix-WhatsApp definitely does.