Skip to content

Fix bridges var naming #5096

@jbgrim

Description

@jbgrim

Describe the bug
All of the variables for configuring bridges are inconsistant and there is sometimes errors in them.

For instance, when configuring custom username prefix for the mautrix meta bridge, regex characters are not escaped in the appservice registration file.

Moreover, this option is not available for other bridges, which makes me totally rewrite all the configuration for each bridge I add.

Also for some reason there is sometimes a ...appservice_username var, and sometimes it is a ...appservice_bot_username var.

To Reproduce
My vars.yml file looks like this:

# WhatsApp
matrix_mautrix_whatsapp_enabled: true
matrix_mautrix_whatsapp_appservice_bot_username: "bridge.whatsapp"
matrix_mautrix_whatsapp_bridge_username_prefix: "bridge.whatsapp."
matrix_mautrix_whatsapp_configuration_extension_yaml: |
  appservice:
    username_template: "{{ matrix_mautrix_whatsapp_bridge_username_prefix + '{{.}}' }}"
matrix_mautrix_whatsapp_registration_yaml: |
  id: whatsapp
  url: {{ matrix_mautrix_whatsapp_appservice_address }}
  as_token: "{{ matrix_mautrix_whatsapp_appservice_token }}"
  hs_token: "{{ matrix_mautrix_whatsapp_homeserver_token }}"
  # See https://github.com/mautrix/signal/issues/43
  sender_localpart: _bot_{{ matrix_mautrix_whatsapp_appservice_bot_username }}
  rate_limited: false
  namespaces:
      users:
      - regex: '^@{{ matrix_mautrix_whatsapp_bridge_username_prefix | regex_escape }}.*:{{ matrix_mautrix_whatsapp_homeserver_domain | regex_escape }}$'
        exclusive: true
      - exclusive: true
        regex: '^@{{ matrix_mautrix_whatsapp_appservice_bot_username | regex_escape }}:{{ matrix_mautrix_whatsapp_homeserver_domain | regex_escape }}$'
  de.sorunome.msc2409.push_ephemeral: true
  receive_ephemeral: true
  io.element.msc4190: {{ matrix_mautrix_whatsapp_msc4190_enabled | to_json }}
# Messenger
matrix_mautrix_meta_messenger_enabled: true
matrix_mautrix_meta_messenger_appservice_username: "bridge.messenger"
matrix_mautrix_meta_messenger_bridge_username_prefix: "bridge.messenger."
matrix_mautrix_meta_messenger_registration_yaml: |
  id: {{ matrix_mautrix_meta_messenger_appservice_id | to_json }}
  as_token: {{ matrix_mautrix_meta_messenger_appservice_token | to_json }}
  hs_token: {{ matrix_mautrix_meta_messenger_homeserver_token | to_json }}
  namespaces:
    users:
    - exclusive: true
      regex: '^@{{ matrix_mautrix_meta_messenger_bridge_username_prefix | regex_escape }}.+:{{ matrix_mautrix_meta_messenger_homeserver_domain | regex_escape }}$'
    - exclusive: true
      regex: '^@{{ matrix_mautrix_meta_messenger_appservice_username | regex_escape }}:{{ matrix_mautrix_meta_messenger_homeserver_domain | regex_escape }}$'
  url: {{ matrix_mautrix_meta_messenger_appservice_address }}
  sender_localpart: _bot_{{ matrix_mautrix_meta_messenger_appservice_username }}
  rate_limited: false
  de.sorunome.msc2409.push_ephemeral: true
  receive_ephemeral: true
  io.element.msc4190: {{ matrix_mautrix_meta_messenger_msc4190_enabled | to_json }}
# Instagram
matrix_mautrix_meta_instagram_enabled: true
matrix_mautrix_meta_instagram_appservice_username: "bridge.instagram"
matrix_mautrix_meta_instagram_bridge_username_prefix: "bridge.instagram."
matrix_mautrix_meta_instagram_registration_yaml: |
  id: {{ matrix_mautrix_meta_instagram_appservice_id | to_json }}
  as_token: {{ matrix_mautrix_meta_instagram_appservice_token | to_json }}
  hs_token: {{ matrix_mautrix_meta_instagram_homeserver_token | to_json }}
  namespaces:
    users:
    - exclusive: true
      regex: '^@{{ matrix_mautrix_meta_instagram_bridge_username_prefix | regex_escape }}.+:{{ matrix_mautrix_meta_instagram_homeserver_domain | regex_escape }}$'
    - exclusive: true
      regex: '^@{{ matrix_mautrix_meta_instagram_appservice_username | regex_escape }}:{{ matrix_mautrix_meta_instagram_homeserver_domain | regex_escape }}$'
  url: {{ matrix_mautrix_meta_instagram_appservice_address }}
  sender_localpart: _bot_{{ matrix_mautrix_meta_instagram_appservice_username }}
  rate_limited: false
  de.sorunome.msc2409.push_ephemeral: true
  receive_ephemeral: true
  io.element.msc4190: {{ matrix_mautrix_meta_instagram_msc4190_enabled | to_json }}
# Discord
matrix_mautrix_discord_enabled: true
matrix_mautrix_discord_appservice_bot_username: "bridge.discord"
matrix_mautrix_discord_bridge_username_prefix: "bridge.discord."
matrix_mautrix_discord_bridge_username_template: "{{ matrix_mautrix_discord_bridge_username_prefix + '{{.}}' }}"
matrix_mautrix_discord_registration_yaml: |
  id: discord
  url: {{ matrix_mautrix_discord_appservice_address }}
  as_token: "{{ matrix_mautrix_discord_appservice_token }}"
  hs_token: "{{ matrix_mautrix_discord_homeserver_token }}"
  # See https://github.com/mautrix/signal/issues/43
  sender_localpart: _bot_{{ matrix_mautrix_discord_appservice_bot_username }}
  rate_limited: false
  namespaces:
      users:
      - regex: '^@{{ matrix_mautrix_discord_bridge_username_prefix | regex_escape }}[0-9]+:{{ matrix_mautrix_discord_homeserver_domain | regex_escape }}$'
        exclusive: true
      - exclusive: true
        regex: '^@{{ matrix_mautrix_discord_appservice_bot_username | regex_escape }}:{{ matrix_mautrix_discord_homeserver_domain | regex_escape }}$'
  de.sorunome.msc2409.push_ephemeral: true
  receive_ephemeral: true
  io.element.msc4190: {{ matrix_mautrix_discord_msc4190_enabled | to_json }}

Expected behavior

The problem is that these vars sould not be set in my personnal config file but instead in the default vars.yaml for each bridge.

Matrix Server:
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions