matrix-docker-ansible-deploy icon indicating copy to clipboard operation
matrix-docker-ansible-deploy copied to clipboard

Issues setting up mautrix bridges with dendrite

Open nickypro opened this issue 2 years ago • 10 comments

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
  1. 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.

nickypro avatar Feb 09 '22 10:02 nickypro

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:

  • matrix_synapse_container_extra_arguments -> matrix_dendrite_container_extra_arguments
  • matrix_synapse_app_service_config_files -> matrix_dendrite_app_service_config_files

.. 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)

spantaleev avatar Feb 09 '22 12:02 spantaleev

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

nickypro avatar Feb 09 '22 16:02 nickypro

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

edgar-vincent avatar Jul 05 '22 12:07 edgar-vincent

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

Kab1r avatar Jul 05 '22 16:07 Kab1r

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?

madprogramer avatar Aug 04 '22 21:08 madprogramer

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?

shalzz avatar Aug 18 '22 00:08 shalzz

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

madprogramer avatar Aug 23 '22 07:08 madprogramer

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

spantaleev avatar Aug 24 '22 04:08 spantaleev

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.

ibeckermayer avatar Dec 07 '22 04:12 ibeckermayer

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

Kab1r avatar Dec 07 '22 04:12 Kab1r