From 8767f50d4672c2e443dd78a0e7453fc26b551e9e Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sun, 8 Feb 2026 17:33:34 -0800 Subject: [PATCH 01/23] Add iMessage RustPush bridge (matrix-bridge-imessage-rustpush) New role for bridging Matrix <-> iMessage using RustPush (lrhodin/imessage). --- ...uring-playbook-bridge-imessage-rustpush.md | 93 ++++++++ ...aybook-bridge-imessage-rustpush.md.license | 3 + group_vars/matrix_servers | 93 ++++++++ .../defaults/main.yml | 222 ++++++++++++++++++ .../tasks/main.yml | 24 ++ .../tasks/setup_install.yml | 115 +++++++++ .../tasks/setup_uninstall.yml | 23 ++ .../tasks/validate_config.yml | 19 ++ .../templates/Dockerfile.j2 | 45 ++++ .../templates/Dockerfile.j2.license | 3 + .../templates/config.yaml.j2 | 190 +++++++++++++++ .../templates/config.yaml.j2.license | 3 + .../templates/labels.j2 | 52 ++++ .../templates/labels.j2.license | 3 + .../matrix-imessage-rustpush.service.j2 | 48 ++++ ...atrix-imessage-rustpush.service.j2.license | 3 + setup.yml | 1 + 17 files changed, 940 insertions(+) create mode 100644 docs/configuring-playbook-bridge-imessage-rustpush.md create mode 100644 docs/configuring-playbook-bridge-imessage-rustpush.md.license create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/tasks/main.yml create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_uninstall.yml create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2 create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2.license create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2 create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2.license create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2.license create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 create mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2.license diff --git a/docs/configuring-playbook-bridge-imessage-rustpush.md b/docs/configuring-playbook-bridge-imessage-rustpush.md new file mode 100644 index 000000000..3db2e5250 --- /dev/null +++ b/docs/configuring-playbook-bridge-imessage-rustpush.md @@ -0,0 +1,93 @@ + + +# Setting up iMessage RustPush bridging (optional) + +Refer the common guide for configuring mautrix bridges: [Setting up a Generic Mautrix Bridge](configuring-playbook-bridge-mautrix-bridges.md) + +The playbook can install and configure [mautrix-imessage with RustPush](https://github.com/lrhodin/imessage) for you, which provides a bridge to [iMessage](https://support.apple.com/messages) using Apple's push notification service (no Mac needed at runtime). + +See the project's [documentation](https://github.com/lrhodin/imessage/blob/main/README.md) to learn what it does and why it might be useful to you. + +**Note**: This bridge is built from source (no pre-built Docker image exists). The build process requires Rust, Go, and C toolchains, which means the initial build will take significant time and resources. + +## Prerequisites + +### Hardware Key Extraction + +To use this bridge on Linux (Docker), you need a **hardware key** extracted from a real Mac. This key contains hardware identifiers needed for iMessage registration. + +The key is entered interactively through the bridge bot's login flow (not configured via Ansible variables). See the upstream [README](https://github.com/lrhodin/imessage/blob/main/README.md) for instructions on extracting the key. + +### Enable Appservice Double Puppet (optional) + +If you want to set up [Double Puppeting](https://docs.mau.fi/bridges/general/double-puppeting.html) (hint: you most likely do) for this bridge automatically, you need to have enabled [Appservice Double Puppet](configuring-playbook-appservice-double-puppet.md) service for this playbook. + +See [this section](configuring-playbook-bridge-mautrix-bridges.md#set-up-double-puppeting-optional) on the [common guide for configuring mautrix bridges](configuring-playbook-bridge-mautrix-bridges.md) for details about setting up Double Puppeting. + +## Adjusting the playbook configuration + +To enable the bridge, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file: + +```yaml +matrix_imessage_rustpush_enabled: true +``` + +### Backfill (optional) + +Backfill is disabled by default because Linux Docker cannot access the macOS `chat.db` file. If you are running on macOS with Full Disk Access, you can enable it: + +```yaml +matrix_imessage_rustpush_backfill_enabled: true +matrix_imessage_rustpush_initial_sync_days: 365 +``` + +### Extending the configuration + +There are some additional things you may wish to configure about the bridge. + +See [this section](configuring-playbook-bridge-mautrix-bridges.md#extending-the-configuration) on the [common guide for configuring mautrix bridges](configuring-playbook-bridge-mautrix-bridges.md) for details about variables that you can customize and the bridge's default configuration, including [bridge permissions](configuring-playbook-bridge-mautrix-bridges.md#configure-bridge-permissions-optional), [encryption support](configuring-playbook-bridge-mautrix-bridges.md#enable-encryption-optional), [bot's username](configuring-playbook-bridge-mautrix-bridges.md#set-the-bots-username-optional), etc. + +## Installing + +After configuring the playbook, run it with [playbook tags](playbook-tags.md) as below: + + +```sh +ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start +``` + +**Notes**: + +- The shortcut commands with the [`just` program](just.md) are also available: `just install-all` or `just setup-all` + + `just install-all` is useful for maintaining your setup quickly ([2x-5x faster](../CHANGELOG.md#2x-5x-performance-improvements-in-playbook-runtime) than `just setup-all`) when its components remain unchanged. If you adjust your `vars.yml` to remove other components, you'd need to run `just setup-all`, or these components will still remain installed. + +- The first run will take longer than usual because the Docker image is built from source (Rust + Go compilation). + +## Usage + +To use the bridge, you need to start a chat with `@imessagebot:example.com` (where `example.com` is your base domain, not the `matrix.` domain). + +The bridge supports two login flows: + +1. **External Key Login** (Linux/Docker): Enter your hardware key (base64), then Apple ID credentials and 2FA code. +2. **Apple ID Login** (macOS only): Enter Apple ID credentials and 2FA code directly. + +After logging in, the bridge will start receiving iMessages and creating portal rooms. + +## Troubleshooting + +As with all other services, you can find the logs in [systemd-journald](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html) by logging in to the server with SSH and running `journalctl -fu matrix-imessage-rustpush`. + +### Increase logging verbosity + +The default logging level for this component is `warn`. If you want to increase the verbosity, add the following configuration to your `vars.yml` file and re-run the playbook: + +```yaml +# Valid values: fatal, error, warn, info, debug, trace +matrix_imessage_rustpush_logging_level: 'debug' +``` diff --git a/docs/configuring-playbook-bridge-imessage-rustpush.md.license b/docs/configuring-playbook-bridge-imessage-rustpush.md.license new file mode 100644 index 000000000..826be4a75 --- /dev/null +++ b/docs/configuring-playbook-bridge-imessage-rustpush.md.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index b46f0bfc4..9269b15f4 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -114,6 +114,8 @@ matrix_homeserver_container_extra_arguments_auto: | + (['--mount type=bind,src=' + matrix_mautrix_bluesky_config_path + '/registration.yaml,dst=/matrix-mautrix-bluesky-registration.yaml,ro'] if matrix_mautrix_bluesky_enabled else []) + + (['--mount type=bind,src=' + matrix_imessage_rustpush_config_path + '/registration.yaml,dst=/matrix-imessage-rustpush-registration.yaml,ro'] if matrix_imessage_rustpush_enabled else []) + + (['--mount type=bind,src=' + matrix_mautrix_discord_config_path + '/registration.yaml,dst=/matrix-mautrix-discord-registration.yaml,ro'] if matrix_mautrix_discord_enabled else []) + (['--mount type=bind,src=' + matrix_mautrix_slack_config_path + '/registration.yaml,dst=/matrix-mautrix-slack-registration.yaml,ro'] if matrix_mautrix_slack_enabled else []) @@ -171,6 +173,8 @@ matrix_homeserver_app_service_config_files_auto: | + (['/matrix-mautrix-bluesky-registration.yaml'] if matrix_mautrix_bluesky_enabled else []) + + (['/matrix-imessage-rustpush-registration.yaml'] if matrix_imessage_rustpush_enabled else []) + + (['/matrix-mautrix-discord-registration.yaml'] if matrix_mautrix_discord_enabled else []) + (['/matrix-mautrix-slack-registration.yaml'] if matrix_mautrix_slack_enabled else []) @@ -436,6 +440,13 @@ devture_systemd_service_manager_services_list_auto: | 'groups': ['matrix', 'bridges', 'mautrix-bluesky'], }] if matrix_mautrix_bluesky_enabled else []) + + ([{ + 'name': 'matrix-imessage-rustpush.service', + 'priority': 2000, + 'restart_necessary': (matrix_imessage_rustpush_restart_necessary | bool), + 'groups': ['matrix', 'bridges', 'imessage-rustpush'], + }] if matrix_imessage_rustpush_enabled else []) + + ([{ 'name': 'matrix-mautrix-discord.service', 'priority': 2000, @@ -1469,6 +1480,77 @@ matrix_mautrix_bluesky_database_password: "{{ (matrix_homeserver_generic_secret_ # ###################################################################### + +###################################################################### +# +# matrix-bridge-imessage-rustpush +# +###################################################################### + +# We don't enable bridges by default. +matrix_imessage_rustpush_enabled: false + +matrix_imessage_rustpush_systemd_required_services_list_auto: | + {{ + matrix_addons_homeserver_systemd_services_list + + + ([postgres_identifier ~ '.service'] if (postgres_enabled and matrix_imessage_rustpush_database_hostname == postgres_connection_hostname) else []) + }} + +matrix_imessage_rustpush_container_network: "{{ matrix_addons_container_network }}" + +matrix_imessage_rustpush_container_additional_networks_auto: |- + {{ + ( + ([] if matrix_addons_homeserver_container_network == '' else [matrix_addons_homeserver_container_network]) + + + ([postgres_container_network] if (postgres_enabled and matrix_imessage_rustpush_database_hostname == postgres_connection_hostname and matrix_imessage_rustpush_container_network != postgres_container_network) else []) + + + ([matrix_playbook_reverse_proxyable_services_additional_network] if matrix_playbook_reverse_proxyable_services_additional_network and matrix_imessage_rustpush_container_labels_traefik_enabled else []) + ) | unique + }} + +matrix_imessage_rustpush_container_labels_traefik_enabled: "{{ matrix_playbook_reverse_proxy_type in ['playbook-managed-traefik', 'other-traefik-container'] }}" +matrix_imessage_rustpush_container_labels_traefik_docker_network: "{{ matrix_playbook_reverse_proxyable_services_additional_network }}" +matrix_imessage_rustpush_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" +matrix_imessage_rustpush_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" + +matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_enabled: "{{ matrix_metrics_exposure_http_basic_auth_enabled }}" +matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_users: "{{ matrix_metrics_exposure_http_basic_auth_users }}" + +matrix_imessage_rustpush_appservice_token: "{{ (matrix_homeserver_generic_secret_key + ':imsg.as.token') | hash('sha512') | to_uuid }}" + +matrix_imessage_rustpush_homeserver_address: "{{ matrix_addons_homeserver_client_api_url }}" +matrix_imessage_rustpush_homeserver_token: "{{ (matrix_homeserver_generic_secret_key + ':imsg.hs.token') | hash('sha512') | to_uuid }}" + +matrix_imessage_rustpush_homeserver_async_media: "{{ matrix_homeserver_implementation in ['synapse'] }}" + +matrix_imessage_rustpush_provisioning_shared_secret: "{{ (matrix_homeserver_generic_secret_key + ':mau.imsg.prov') | hash('sha512') | to_uuid }}" + +matrix_imessage_rustpush_double_puppet_secrets_auto: |- + {{ + ({ + matrix_imessage_rustpush_homeserver_domain: ("as_token:" + matrix_appservice_double_puppet_registration_as_token) + }) + if matrix_appservice_double_puppet_enabled + else {} + }} + +matrix_imessage_rustpush_metrics_enabled: "{{ prometheus_enabled or matrix_metrics_exposure_enabled }}" + +matrix_imessage_rustpush_metrics_proxying_enabled: "{{ matrix_imessage_rustpush_metrics_enabled and matrix_metrics_exposure_enabled }}" +matrix_imessage_rustpush_metrics_proxying_hostname: "{{ matrix_metrics_exposure_hostname }}" +matrix_imessage_rustpush_metrics_proxying_path_prefix: "{{ matrix_metrics_exposure_path_prefix }}/imessage-rustpush" + +matrix_imessage_rustpush_database_hostname: "{{ postgres_connection_hostname if postgres_enabled else '' }}" +matrix_imessage_rustpush_database_password: "{{ (matrix_homeserver_generic_secret_key + ':mau.imsg.db') | hash('sha512') | to_uuid if postgres_enabled else '' }}" + +###################################################################### +# +# /matrix-bridge-imessage-rustpush +# +###################################################################### + ###################################################################### # # matrix-bridge-mautrix-discord @@ -4052,6 +4134,12 @@ postgres_managed_databases_auto: | 'password': matrix_mautrix_bluesky_database_password, }] if (matrix_mautrix_bluesky_enabled and matrix_mautrix_bluesky_database_engine == 'postgres' and matrix_mautrix_bluesky_database_hostname == postgres_connection_hostname) else []) + + ([{ + 'name': matrix_imessage_rustpush_database_name, + 'username': matrix_imessage_rustpush_database_username, + 'password': matrix_imessage_rustpush_database_password, + }] if (matrix_imessage_rustpush_enabled and matrix_imessage_rustpush_database_engine == 'postgres' and matrix_imessage_rustpush_database_hostname == postgres_connection_hostname) else []) + + ([{ 'name': matrix_mautrix_googlechat_database_name, 'username': matrix_mautrix_googlechat_database_username, @@ -4992,6 +5080,11 @@ matrix_ketesa_config_asManagedUsers_auto: | '^@bluesky_[a-zA-Z0-9]+:'+(matrix_domain | regex_escape)+'$', ] if matrix_mautrix_bluesky_enabled else []) + + ([ + '^@'+(matrix_imessage_rustpush_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', + '^@imessage_[a-zA-Z0-9_.+-]+:'+(matrix_domain | regex_escape)+'$', + ] if matrix_imessage_rustpush_enabled else []) + + ([ '^@'+(matrix_mautrix_discord_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', '^@discord_[0-9]+:'+(matrix_domain | regex_escape)+'$', diff --git a/roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml new file mode 100644 index 000000000..c0ae1cb31 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml @@ -0,0 +1,222 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- +# matrix-bridge-imessage-rustpush is a Matrix <-> iMessage bridge using RustPush +# Project source code URL: https://github.com/lrhodin/imessage + +matrix_imessage_rustpush_enabled: true + +# No upstream Docker image exists; self-build is always required. +matrix_imessage_rustpush_container_image_self_build: true +matrix_imessage_rustpush_container_image_self_build_repo: "https://github.com/lrhodin/imessage.git" +matrix_imessage_rustpush_container_image_self_build_repo_version: "{{ 'main' if matrix_imessage_rustpush_version == 'latest' else matrix_imessage_rustpush_version }}" + +matrix_imessage_rustpush_version: latest +matrix_imessage_rustpush_docker_image: "{{ matrix_imessage_rustpush_docker_image_registry_prefix }}lrhodin/imessage:{{ matrix_imessage_rustpush_version }}" +matrix_imessage_rustpush_docker_image_registry_prefix: "localhost/" +matrix_imessage_rustpush_docker_image_force_pull: "{{ matrix_imessage_rustpush_docker_image.endswith(':latest') }}" + +matrix_imessage_rustpush_base_path: "{{ matrix_base_data_path }}/imessage-rustpush" +matrix_imessage_rustpush_config_path: "{{ matrix_imessage_rustpush_base_path }}/config" +matrix_imessage_rustpush_data_path: "{{ matrix_imessage_rustpush_base_path }}/data" +matrix_imessage_rustpush_docker_src_files_path: "{{ matrix_imessage_rustpush_base_path }}/docker-src" + +matrix_imessage_rustpush_homeserver_address: "" +# Whether asynchronous uploads via MSC2246 should be enabled for media. +matrix_imessage_rustpush_homeserver_async_media: false +matrix_imessage_rustpush_homeserver_domain: '{{ matrix_domain }}' +matrix_imessage_rustpush_appservice_address: 'http://matrix-imessage-rustpush:8081' + +matrix_imessage_rustpush_msc4190_enabled: "{{ matrix_bridges_msc4190_enabled }}" +matrix_imessage_rustpush_self_sign_enabled: "{{ matrix_bridges_self_sign_enabled }}" + +# A public address that external services can use to reach this appservice. +matrix_imessage_rustpush_appservice_public_address: '' + +# Displayname template for iMessage contacts. +# Available variables: {{.FirstName}}, {{.LastName}}, {{.Nickname}}, +# {{.Phone}}, {{.Email}}, {{.ID}} +matrix_imessage_rustpush_network_displayname_template: "{% raw %}{{if .FirstName}}{{.FirstName}}{{if .LastName}} {{.LastName}}{{end}}{{else if .Nickname}}{{.Nickname}}{{else if .Phone}}{{.Phone}}{{else if .Email}}{{.Email}}{{else}}{{.ID}}{{end}}{% endraw %}" + +matrix_imessage_rustpush_bridge_command_prefix: "!imessage" + +matrix_imessage_rustpush_bridge_permissions: | + {{ + {matrix_imessage_rustpush_homeserver_domain: 'user'} + | combine({matrix_admin: 'admin'} if matrix_admin else {}) + }} + +matrix_imessage_rustpush_container_network: "" + +matrix_imessage_rustpush_container_additional_networks: "{{ matrix_imessage_rustpush_container_additional_networks_auto + matrix_imessage_rustpush_container_additional_networks_custom }}" +matrix_imessage_rustpush_container_additional_networks_auto: [] +matrix_imessage_rustpush_container_additional_networks_custom: [] + +# matrix_imessage_rustpush_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container. +# See `../templates/labels.j2` for details. +# +# To inject your own other container labels, see `matrix_imessage_rustpush_container_labels_additional_labels`. +matrix_imessage_rustpush_container_labels_traefik_enabled: true +matrix_imessage_rustpush_container_labels_traefik_docker_network: "{{ matrix_imessage_rustpush_container_network }}" +matrix_imessage_rustpush_container_labels_traefik_entrypoints: web-secure +matrix_imessage_rustpush_container_labels_traefik_tls_certResolver: default # noqa var-naming + +# Controls whether labels will be added that expose metrics +matrix_imessage_rustpush_container_labels_metrics_enabled: "{{ matrix_imessage_rustpush_metrics_enabled and matrix_imessage_rustpush_metrics_proxying_enabled }}" +matrix_imessage_rustpush_container_labels_metrics_traefik_rule: "Host(`{{ matrix_imessage_rustpush_metrics_proxying_hostname }}`) && PathPrefix(`{{ matrix_imessage_rustpush_metrics_proxying_path_prefix }}`)" +matrix_imessage_rustpush_container_labels_metrics_traefik_priority: 0 +matrix_imessage_rustpush_container_labels_metrics_traefik_entrypoints: "{{ matrix_imessage_rustpush_container_labels_traefik_entrypoints }}" +matrix_imessage_rustpush_container_labels_metrics_traefik_tls: "{{ matrix_imessage_rustpush_container_labels_metrics_traefik_entrypoints != 'web' }}" +matrix_imessage_rustpush_container_labels_metrics_traefik_tls_certResolver: "{{ matrix_imessage_rustpush_container_labels_traefik_tls_certResolver }}" # noqa var-naming +matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_enabled: false +# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users +matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_users: '' + +# matrix_imessage_rustpush_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file. +# See `../templates/labels.j2` for details. +# +# Example: +# matrix_imessage_rustpush_container_labels_additional_labels: | +# my.label=1 +# another.label="here" +matrix_imessage_rustpush_container_labels_additional_labels: '' + +# A list of extra arguments to pass to the container +matrix_imessage_rustpush_container_extra_arguments: [] + +# List of systemd services that matrix-imessage-rustpush.service depends on. +matrix_imessage_rustpush_systemd_required_services_list: "{{ matrix_imessage_rustpush_systemd_required_services_list_default + matrix_imessage_rustpush_systemd_required_services_list_auto + matrix_imessage_rustpush_systemd_required_services_list_custom }}" +matrix_imessage_rustpush_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" +matrix_imessage_rustpush_systemd_required_services_list_auto: [] +matrix_imessage_rustpush_systemd_required_services_list_custom: [] + +# List of systemd services that matrix-imessage-rustpush.service wants +matrix_imessage_rustpush_systemd_wanted_services_list: [] + +matrix_imessage_rustpush_appservice_token: '' +matrix_imessage_rustpush_homeserver_token: '' + +# Whether or not created rooms should have federation enabled. +# If false, created portal rooms will never be federated. +matrix_imessage_rustpush_matrix_federate_rooms: true + +# Database-related configuration fields. +# +# To use Postgres: +# - adjust your database credentials via the `matrix_imessage_rustpush_postgres_*` variables +matrix_imessage_rustpush_database_engine: 'postgres' + +matrix_imessage_rustpush_database_username: 'matrix_imessage_rustpush' +matrix_imessage_rustpush_database_password: 'some-password' +matrix_imessage_rustpush_database_hostname: '' +matrix_imessage_rustpush_database_port: 5432 +matrix_imessage_rustpush_database_name: 'matrix_imessage_rustpush' +matrix_imessage_rustpush_database_sslmode: disable + +matrix_imessage_rustpush_database_connection_string: 'postgres://{{ matrix_imessage_rustpush_database_username }}:{{ matrix_imessage_rustpush_database_password }}@{{ matrix_imessage_rustpush_database_hostname }}:{{ matrix_imessage_rustpush_database_port }}/{{ matrix_imessage_rustpush_database_name }}?sslmode={{ matrix_imessage_rustpush_database_sslmode }}' + +matrix_imessage_rustpush_database_uri: "{{ + { + 'postgres': matrix_imessage_rustpush_database_connection_string, + }[matrix_imessage_rustpush_database_engine] +}}" + +matrix_imessage_rustpush_double_puppet_secrets: "{{ matrix_imessage_rustpush_double_puppet_secrets_auto | combine(matrix_imessage_rustpush_double_puppet_secrets_custom) }}" +matrix_imessage_rustpush_double_puppet_secrets_auto: {} +matrix_imessage_rustpush_double_puppet_secrets_custom: {} + +matrix_imessage_rustpush_appservice_bot_username: imessagebot +matrix_imessage_rustpush_appservice_bot_displayname: iMessage bridge bot +matrix_imessage_rustpush_appservice_bot_avatar: '' + +# Backfill is disabled by default because Linux Docker cannot access chat.db. +# On macOS with Full Disk Access, this can be set to true. +matrix_imessage_rustpush_backfill_enabled: false +# Maximum number of messages to backfill in empty rooms +matrix_imessage_rustpush_backfill_max_initial_messages: 50 + +# Maximum number of missed messages to backfill after bridge restarts +matrix_imessage_rustpush_backfill_max_catchup_messages: 500 + +# How many days back to look for chats during initial sync. +# Default in upstream is 365 (1 year). Set to 0 to disable. +matrix_imessage_rustpush_initial_sync_days: 0 + +# Shared secret for authentication of provisioning API requests. +# If set to "disable", the provisioning API will be disabled. +matrix_imessage_rustpush_provisioning_shared_secret: disable + +# Minimum severity of journal log messages. +# Valid values: fatal, error, warn, info, debug, trace +matrix_imessage_rustpush_logging_level: 'warn' + +# Whether or not metrics endpoint should be enabled. +# Enabling them is usually enough for a local (in-container) Prometheus to consume them. +# If metrics need to be consumed by another (external) Prometheus server, consider exposing them via `matrix_imessage_rustpush_metrics_proxying_enabled`. +matrix_imessage_rustpush_metrics_enabled: false + +# Controls whether metrics should be exposed on a public URL. +matrix_imessage_rustpush_metrics_proxying_enabled: false +matrix_imessage_rustpush_metrics_proxying_hostname: '' +matrix_imessage_rustpush_metrics_proxying_path_prefix: '' + +# Default configuration template which covers the generic use case. +# You can customize it by controlling the various variables inside it. +# +# For a more advanced customization, you can extend the default (see `matrix_imessage_rustpush_configuration_extension_yaml`) +# or completely replace this variable with your own template. +matrix_imessage_rustpush_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}" + +matrix_imessage_rustpush_configuration_extension_yaml: | + # Your custom YAML configuration goes here. + # This configuration extends the default starting configuration (`matrix_imessage_rustpush_configuration_yaml`). + # + # You can override individual variables from the default configuration, or introduce new ones. + # + # If you need something more special, you can take full control by + # completely redefining `matrix_imessage_rustpush_configuration_yaml`. + +matrix_imessage_rustpush_configuration_extension: "{{ matrix_imessage_rustpush_configuration_extension_yaml | from_yaml if matrix_imessage_rustpush_configuration_extension_yaml | from_yaml is mapping else {} }}" + +# Holds the final configuration (a combination of the default and its extension). +# You most likely don't need to touch this variable. Instead, see `matrix_imessage_rustpush_configuration_yaml`. +matrix_imessage_rustpush_configuration: "{{ matrix_imessage_rustpush_configuration_yaml | from_yaml | combine(matrix_imessage_rustpush_configuration_extension, recursive=True) }}" + +matrix_imessage_rustpush_registration_yaml: | + id: imessage-rustpush + as_token: "{{ matrix_imessage_rustpush_appservice_token }}" + hs_token: "{{ matrix_imessage_rustpush_homeserver_token }}" + namespaces: + users: + - exclusive: true + regex: '^@imessage_.+:{{ matrix_imessage_rustpush_homeserver_domain | regex_escape }}$' + - exclusive: true + regex: '^@{{ matrix_imessage_rustpush_appservice_bot_username | regex_escape }}:{{ matrix_imessage_rustpush_homeserver_domain | regex_escape }}$' + url: {{ matrix_imessage_rustpush_appservice_address }} + sender_localpart: _bot_{{ matrix_imessage_rustpush_appservice_bot_username }} + rate_limited: false + de.sorunome.msc2409.push_ephemeral: true + receive_ephemeral: true + io.element.msc4190: {{ matrix_imessage_rustpush_msc4190_enabled | to_json }} + +matrix_imessage_rustpush_registration: "{{ matrix_imessage_rustpush_registration_yaml | from_yaml }}" + +# Enable End-to-bridge encryption +matrix_imessage_rustpush_bridge_encryption_allow: "{{ matrix_bridges_encryption_enabled }}" +matrix_imessage_rustpush_bridge_encryption_default: "{{ matrix_bridges_encryption_default }}" +matrix_imessage_rustpush_bridge_encryption_require: false +matrix_imessage_rustpush_bridge_encryption_appservice: false +matrix_imessage_rustpush_bridge_encryption_key_sharing_allow: "{{ matrix_imessage_rustpush_bridge_encryption_allow }}" +matrix_imessage_rustpush_bridge_encryption_pickle_key: mautrix.bridge.e2ee + +# matrix_imessage_rustpush_restart_necessary controls whether the service +# will be restarted (when true) or merely started (when false) by the +# systemd service manager role (when conditional restart is enabled). +# +# This value is automatically computed during installation based on whether +# any configuration files, the systemd service file, or the container image changed. +# The default of `false` means "no restart needed" — appropriate when the role's +# installation tasks haven't run (e.g., due to --tags skipping them). +matrix_imessage_rustpush_restart_necessary: false diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/main.yml b/roles/custom/matrix-bridge-imessage-rustpush/tasks/main.yml new file mode 100644 index 000000000..a6cd72ef0 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/tasks/main.yml @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- + +- tags: + - setup-all + - setup-imessage-rustpush + - install-all + - install-imessage-rustpush + block: + - when: matrix_imessage_rustpush_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + + - when: matrix_imessage_rustpush_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" + +- tags: + - setup-all + - setup-imessage-rustpush + block: + - when: not matrix_imessage_rustpush_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml b/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml new file mode 100644 index 000000000..0fe6e7285 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml @@ -0,0 +1,115 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- + +- name: Ensure iMessage RustPush paths exist + ansible.builtin.file: + path: "{{ item.path }}" + state: directory + mode: 0750 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + with_items: + - {path: "{{ matrix_imessage_rustpush_base_path }}", when: true} + - {path: "{{ matrix_imessage_rustpush_config_path }}", when: true} + - {path: "{{ matrix_imessage_rustpush_data_path }}", when: true} + - {path: "{{ matrix_imessage_rustpush_docker_src_files_path }}", when: "{{ matrix_imessage_rustpush_container_image_self_build }}"} + when: item.when | bool + +- name: Ensure iMessage RustPush repository is present on self-build + ansible.builtin.git: + repo: "{{ matrix_imessage_rustpush_container_image_self_build_repo }}" + version: "{{ matrix_imessage_rustpush_container_image_self_build_repo_version }}" + dest: "{{ matrix_imessage_rustpush_docker_src_files_path }}" + force: "yes" + become: true + become_user: "{{ matrix_user_name }}" + register: matrix_imessage_rustpush_git_pull_results + when: "matrix_imessage_rustpush_enabled | bool and matrix_imessage_rustpush_container_image_self_build" + +- name: Ensure iMessage RustPush Dockerfile is installed + ansible.builtin.template: + src: "{{ role_path }}/templates/Dockerfile.j2" + dest: "{{ matrix_imessage_rustpush_docker_src_files_path }}/Dockerfile" + mode: 0640 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + when: "matrix_imessage_rustpush_enabled | bool and matrix_imessage_rustpush_container_image_self_build | bool" + +- name: Ensure iMessage RustPush Docker image is built + community.docker.docker_image: + name: "{{ matrix_imessage_rustpush_docker_image }}" + source: build + force_source: "{{ matrix_imessage_rustpush_git_pull_results.changed if matrix_imessage_rustpush_git_pull_results is defined else true }}" + build: + dockerfile: Dockerfile + path: "{{ matrix_imessage_rustpush_docker_src_files_path }}" + pull: true + register: matrix_imessage_rustpush_container_image_build_result + when: "matrix_imessage_rustpush_enabled | bool and matrix_imessage_rustpush_container_image_self_build | bool" + +- name: Ensure iMessage RustPush container image is pulled + community.docker.docker_image: + name: "{{ matrix_imessage_rustpush_docker_image }}" + source: pull + force_source: "{{ matrix_imessage_rustpush_container_image_force_pull if matrix_imessage_rustpush_container_image_force_pull is defined else true }}" + register: matrix_imessage_rustpush_container_image_pull_result + when: "matrix_imessage_rustpush_enabled | bool and not matrix_imessage_rustpush_container_image_self_build | bool" + ignore_errors: "{{ ansible_check_mode }}" + +- name: Ensure imessage-rustpush config.yaml installed + ansible.builtin.copy: + content: "{{ matrix_imessage_rustpush_configuration | to_nice_yaml(indent=2, width=999999) }}" + dest: "{{ matrix_imessage_rustpush_config_path }}/config.yaml" + mode: 0644 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + register: matrix_imessage_rustpush_config_result + +- name: Ensure imessage-rustpush registration.yaml installed + ansible.builtin.copy: + content: "{{ matrix_imessage_rustpush_registration | to_nice_yaml(indent=2, width=999999) }}" + dest: "{{ matrix_imessage_rustpush_config_path }}/registration.yaml" + mode: 0644 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + register: matrix_imessage_rustpush_registration_result + +- name: Ensure imessage-rustpush support files installed + ansible.builtin.template: + src: "{{ role_path }}/templates/{{ item }}.j2" + dest: "{{ matrix_imessage_rustpush_base_path }}/{{ item }}" + mode: 0640 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + with_items: + - labels + register: matrix_imessage_rustpush_support_files_result + +- name: Ensure matrix-imessage-rustpush container network is created + community.general.docker_network: + enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}" + name: "{{ matrix_imessage_rustpush_container_network }}" + driver: bridge + driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}" + +- name: Ensure matrix-imessage-rustpush.service installed + ansible.builtin.template: + src: "{{ role_path }}/templates/systemd/matrix-imessage-rustpush.service.j2" + dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-imessage-rustpush.service" + mode: 0644 + register: matrix_imessage_rustpush_systemd_service_result + +- name: Determine whether matrix-imessage-rustpush needs a restart + ansible.builtin.set_fact: + matrix_imessage_rustpush_restart_necessary: >- + {{ + matrix_imessage_rustpush_config_result.changed | default(false) + or matrix_imessage_rustpush_registration_result.changed | default(false) + or matrix_imessage_rustpush_support_files_result.changed | default(false) + or matrix_imessage_rustpush_systemd_service_result.changed | default(false) + or matrix_imessage_rustpush_container_image_pull_result.changed | default(false) + or matrix_imessage_rustpush_container_image_build_result.changed | default(false) + }} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_uninstall.yml b/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_uninstall.yml new file mode 100644 index 000000000..7ac351bbf --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_uninstall.yml @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- + +- name: Check existence of matrix-imessage-rustpush service + ansible.builtin.stat: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-imessage-rustpush.service" + register: matrix_imessage_rustpush_service_stat + +- when: matrix_imessage_rustpush_service_stat.stat.exists | bool + block: + - name: Ensure matrix-imessage-rustpush is stopped + ansible.builtin.service: + name: matrix-imessage-rustpush + state: stopped + daemon_reload: true + + - name: Ensure matrix-imessage-rustpush.service doesn't exist + ansible.builtin.file: + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-imessage-rustpush.service" + state: absent diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml b/roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml new file mode 100644 index 000000000..d2c846c14 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- + +- name: Fail if required iMessage RustPush settings not defined + ansible.builtin.fail: + msg: >- + You need to define a required configuration setting (`{{ item.name }}`). + when: "item.when | bool and lookup('vars', item.name, default='') | string | length == 0" + with_items: + - {'name': 'matrix_imessage_rustpush_appservice_token', when: true} + - {'name': 'matrix_imessage_rustpush_homeserver_address', when: true} + - {'name': 'matrix_imessage_rustpush_homeserver_token', when: true} + - {'name': 'matrix_imessage_rustpush_database_hostname', when: "{{ matrix_imessage_rustpush_database_engine == 'postgres' }}"} + - {'name': 'matrix_imessage_rustpush_container_network', when: true} + - {'name': 'matrix_imessage_rustpush_metrics_proxying_hostname', when: "{{ matrix_imessage_rustpush_metrics_proxying_enabled }}"} + - {'name': 'matrix_imessage_rustpush_metrics_proxying_path_prefix', when: "{{ matrix_imessage_rustpush_metrics_proxying_enabled }}"} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2 b/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2 new file mode 100644 index 000000000..58baef06b --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2 @@ -0,0 +1,45 @@ +{# +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later +#} + +# Multi-stage build for mautrix-imessage with RustPush support +# Stage 1: Rust + Go builder +FROM docker.io/golang:1.24-bookworm AS builder + +# Install Rust toolchain +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +# Install build dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + clang \ + libclang-dev \ + protobuf-compiler \ + git \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /build + +# Copy the source code +COPY . /build/ + +# Build the Go binary with CGO enabled (required for Rust FFI) +RUN cd /build && make build + +# Stage 2: Runtime +FROM docker.io/debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /build/mautrix-imessage-v2 /usr/bin/mautrix-imessage-v2 + +VOLUME /data +VOLUME /config + +CMD ["/usr/bin/mautrix-imessage-v2", "-c", "/config/config.yaml", "-r", "/config/registration.yaml", "--no-update"] diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2.license b/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2.license new file mode 100644 index 000000000..826be4a75 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2 b/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2 new file mode 100644 index 000000000..ed99483f6 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2 @@ -0,0 +1,190 @@ +#jinja2: lstrip_blocks: True +# Network-specific config options (iMessage via RustPush) +network: + # Displayname template for iMessage contacts. + # Available variables: {{.FirstName}}, {{.LastName}}, {{.Nickname}}, + # {{.Phone}}, {{.Email}}, {{.ID}} + displayname_template: {{ matrix_imessage_rustpush_network_displayname_template | to_json }} + + # How many days back to look for chats during initial sync. + # Default is 365 (1 year). Set to 0 to use the default. + initial_sync_days: {{ matrix_imessage_rustpush_initial_sync_days | to_json }} + +# Config options that affect the central bridge module. +bridge: + # The prefix for commands. Only required in non-management rooms. + command_prefix: {{ matrix_imessage_rustpush_bridge_command_prefix | to_json }} + # Should the bridge create a space for each login containing the rooms that account is in? + personal_filtering_spaces: true + # Whether the bridge should set names and avatars explicitly for DM portals. + private_chat_portal_meta: true + # Should events be handled asynchronously within portal rooms? + async_events: false + # Should every user have their own portals rather than sharing them? + split_portals: false + # Should the bridge resend `m.bridge` events to all portals on startup? + resend_bridge_info: false + + # Should leaving Matrix rooms be bridged as leaving groups on the remote network? + bridge_matrix_leave: false + # Should room tags only be synced when creating the portal? + tag_only_on_create: true + # List of tags to allow bridging. + only_bridge_tags: [m.favourite, m.lowpriority] + # Should room mute status only be synced when creating the portal? + mute_only_on_create: true + + # What should be done to portal rooms when a user logs out or is logged out? + cleanup_on_logout: + enabled: false + manual: + private: nothing + relayed: nothing + shared_no_users: nothing + shared_has_users: nothing + bad_credentials: + private: nothing + relayed: nothing + shared_no_users: nothing + shared_has_users: nothing + + # Settings for relay mode + relay: + enabled: false + admin_only: true + default_relays: [] + message_formats: + m.text: "{% raw %}{{ .Sender.DisambiguatedName }}: {{ .Message }}{% endraw %}" + m.notice: "{% raw %}{{ .Sender.DisambiguatedName }}: {{ .Message }}{% endraw %}" + m.emote: "{% raw %}* {{ .Sender.DisambiguatedName }} {{ .Message }}{% endraw %}" + m.file: "{% raw %}{{ .Sender.DisambiguatedName }} sent a file{{ if .Caption }}: {{ .Caption }}{{ end }}{% endraw %}" + m.image: "{% raw %}{{ .Sender.DisambiguatedName }} sent an image{{ if .Caption }}: {{ .Caption }}{{ end }}{% endraw %}" + m.audio: "{% raw %}{{ .Sender.DisambiguatedName }} sent an audio file{{ if .Caption }}: {{ .Caption }}{{ end }}{% endraw %}" + m.video: "{% raw %}{{ .Sender.DisambiguatedName }} sent a video{{ if .Caption }}: {{ .Caption }}{{ end }}{% endraw %}" + m.location: "{% raw %}{{ .Sender.DisambiguatedName }} sent a location{{ if .Caption }}: {{ .Caption }}{{ end }}{% endraw %}" + displayname_format: "{% raw %}{{ .DisambiguatedName }}{% endraw %}" + + # Permissions for using the bridge. + permissions: {{ matrix_imessage_rustpush_bridge_permissions | to_json }} + +# Config for the bridge's database. +database: + type: postgres + uri: {{ matrix_imessage_rustpush_database_uri | to_json }} + max_open_conns: 5 + max_idle_conns: 1 + max_conn_idle_time: null + max_conn_lifetime: null + +# Homeserver details. +homeserver: + address: {{ matrix_imessage_rustpush_homeserver_address | to_json }} + domain: {{ matrix_imessage_rustpush_homeserver_domain | to_json }} + software: standard + status_endpoint: + message_send_checkpoint_endpoint: + async_media: {{ matrix_imessage_rustpush_homeserver_async_media | to_json }} + websocket: false + ping_interval_seconds: 0 + +# Application service host/registration related details. +appservice: + address: {{ matrix_imessage_rustpush_appservice_address | to_json }} + public_address: {{ matrix_imessage_rustpush_appservice_public_address | to_json }} + + hostname: 0.0.0.0 + port: 8081 + + id: imessage-rustpush + bot: + username: {{ matrix_imessage_rustpush_appservice_bot_username | to_json }} + displayname: {{ matrix_imessage_rustpush_appservice_bot_displayname | to_json(ensure_ascii=False) }} + avatar: {{ matrix_imessage_rustpush_appservice_bot_avatar | to_json }} + + ephemeral_events: true + async_transactions: false + + as_token: {{ matrix_imessage_rustpush_appservice_token | to_json }} + hs_token: {{ matrix_imessage_rustpush_homeserver_token | to_json }} + + # Localpart template of MXIDs for remote users. + username_template: "{% raw %}imessage_{{.}}{% endraw %}" + +# Config options that affect the Matrix connector of the bridge. +matrix: + message_status_events: false + delivery_receipts: false + message_error_notices: true + sync_direct_chat_list: true + federate_rooms: {{ matrix_imessage_rustpush_matrix_federate_rooms | to_json }} + upload_file_threshold: 5242880 + +# Segment-compatible analytics endpoint for tracking some events. +analytics: + token: null + url: https://api.segment.io/v1/track + user_id: null + +# Settings for provisioning API +provisioning: + prefix: /_matrix/provision + shared_secret: {{ matrix_imessage_rustpush_provisioning_shared_secret | to_json }} + allow_matrix_auth: true + debug_endpoints: false + +# Settings for backfilling messages. +backfill: + enabled: {{ matrix_imessage_rustpush_backfill_enabled | to_json }} + max_initial_messages: {{ matrix_imessage_rustpush_backfill_max_initial_messages | to_json }} + max_catchup_messages: {{ matrix_imessage_rustpush_backfill_max_catchup_messages | to_json }} + unread_hours_threshold: 720 + threads: + max_initial_messages: 50 + queue: + enabled: false + batch_size: 100 + batch_delay: 20 + max_batches: -1 + max_batches_override: {} + +# Settings for enabling double puppeting +double_puppet: + servers: {} + allow_discovery: false + secrets: {{ matrix_imessage_rustpush_double_puppet_secrets | to_json }} + +# End-to-bridge encryption support options. +encryption: + allow: {{ matrix_imessage_rustpush_bridge_encryption_allow | to_json }} + default: {{ matrix_imessage_rustpush_bridge_encryption_default | to_json }} + require: {{ matrix_imessage_rustpush_bridge_encryption_require | to_json }} + appservice: {{ matrix_imessage_rustpush_bridge_encryption_appservice | to_json }} + msc4190: {{ matrix_imessage_rustpush_msc4190_enabled | to_json }} + self_sign: {{ matrix_imessage_rustpush_self_sign_enabled | to_json }} + allow_key_sharing: {{ matrix_imessage_rustpush_bridge_encryption_key_sharing_allow | to_json }} + pickle_key: {{ matrix_imessage_rustpush_bridge_encryption_pickle_key | to_json }} + delete_keys: + delete_outbound_on_ack: false + dont_store_outbound: false + ratchet_on_decrypt: false + delete_fully_used_on_decrypt: false + delete_prev_on_new_session: false + delete_on_device_delete: false + periodically_delete_expired: false + delete_outdated_inbound: false + verification_levels: + receive: unverified + send: unverified + share: cross-signed-tofu + rotation: + enable_custom: false + milliseconds: 604800000 + messages: 100 + disable_device_change_key_rotation: false + +# Logging config. +logging: + min_level: {{ matrix_imessage_rustpush_logging_level | to_json }} + writers: + - type: stdout + format: pretty-colored diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2.license b/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2.license new file mode 100644 index 000000000..826be4a75 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 b/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 new file mode 100644 index 000000000..4021967dd --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 @@ -0,0 +1,52 @@ +{# +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later +#} + +{% if matrix_imessage_rustpush_container_labels_traefik_enabled %} +traefik.enable=true + +{% if matrix_imessage_rustpush_container_labels_traefik_docker_network %} +traefik.docker.network={{ matrix_imessage_rustpush_container_labels_traefik_docker_network }} +{% endif %} + +traefik.http.services.matrix-imessage-rustpush-metrics.loadbalancer.server.port=8000 + +{% if matrix_imessage_rustpush_container_labels_metrics_enabled %} +############################################################ +# # +# Metrics # +# # +############################################################ + +{% if matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_enabled %} +traefik.http.middlewares.matrix-imessage-rustpush-metrics-basic-auth.basicauth.users={{ matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_users }} +traefik.http.routers.matrix-imessage-rustpush-metrics.middlewares=matrix-imessage-rustpush-metrics-basic-auth +{% endif %} + +traefik.http.routers.matrix-imessage-rustpush-metrics.rule={{ matrix_imessage_rustpush_container_labels_metrics_traefik_rule }} + +{% if matrix_imessage_rustpush_container_labels_metrics_traefik_priority | int > 0 %} +traefik.http.routers.matrix-imessage-rustpush-metrics.priority={{ matrix_imessage_rustpush_container_labels_metrics_traefik_priority }} +{% endif %} + +traefik.http.routers.matrix-imessage-rustpush-metrics.service=matrix-imessage-rustpush-metrics +traefik.http.routers.matrix-imessage-rustpush-metrics.entrypoints={{ matrix_imessage_rustpush_container_labels_metrics_traefik_entrypoints }} + +traefik.http.routers.matrix-imessage-rustpush-metrics.tls={{ matrix_imessage_rustpush_container_labels_metrics_traefik_tls | to_json }} +{% if matrix_imessage_rustpush_container_labels_metrics_traefik_tls %} +traefik.http.routers.matrix-imessage-rustpush-metrics.tls.certResolver={{ matrix_imessage_rustpush_container_labels_metrics_traefik_tls_certResolver }} +{% endif %} + +############################################################ +# # +# /Metrics # +# # +############################################################ +{% endif %} + + +{% endif %} + +{{ matrix_imessage_rustpush_container_labels_additional_labels }} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2.license b/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2.license new file mode 100644 index 000000000..826be4a75 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 b/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 new file mode 100644 index 000000000..3c40267a2 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 @@ -0,0 +1,48 @@ +#jinja2: lstrip_blocks: True +[Unit] +Description=Matrix iMessage RustPush bridge +{% for service in matrix_imessage_rustpush_systemd_required_services_list %} +Requires={{ service }} +After={{ service }} +{% endfor %} +{% for service in matrix_imessage_rustpush_systemd_wanted_services_list %} +Wants={{ service }} +{% endfor %} +DefaultDependencies=no + +[Service] +Type=simple +Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}" +ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-imessage-rustpush 2>/dev/null || true' +ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-imessage-rustpush 2>/dev/null || true' + +ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ + --rm \ + --name=matrix-imessage-rustpush \ + --log-driver=none \ + --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + --cap-drop=ALL \ + --network={{ matrix_imessage_rustpush_container_network }} \ + --mount type=bind,src={{ matrix_imessage_rustpush_config_path }},dst=/config,ro \ + --mount type=bind,src={{ matrix_imessage_rustpush_data_path }},dst=/data \ + --label-file={{ matrix_imessage_rustpush_base_path }}/labels \ + {% for arg in matrix_imessage_rustpush_container_extra_arguments %} + {{ arg }} \ + {% endfor %} + {{ matrix_imessage_rustpush_docker_image }} \ + /usr/bin/mautrix-imessage-v2 -c /config/config.yaml -r /config/registration.yaml --no-update + +{% for network in matrix_imessage_rustpush_container_additional_networks %} +ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-imessage-rustpush +{% endfor %} + +ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-imessage-rustpush + +ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-imessage-rustpush 2>/dev/null || true' +ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-imessage-rustpush 2>/dev/null || true' +Restart=always +RestartSec=30 +SyslogIdentifier=matrix-imessage-rustpush + +[Install] +WantedBy=multi-user.target diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2.license b/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2.license new file mode 100644 index 000000000..826be4a75 --- /dev/null +++ b/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/setup.yml b/setup.yml index fa136203a..4369a83fe 100644 --- a/setup.yml +++ b/setup.yml @@ -71,6 +71,7 @@ - custom/matrix-bridge-mautrix-discord - custom/matrix-bridge-mautrix-slack - custom/matrix-bridge-mautrix-bluesky + - custom/matrix-bridge-imessage-rustpush - custom/matrix-bridge-mx-puppet-groupme - custom/matrix-bridge-mx-puppet-steam - custom/matrix-bridge-postmoogle From b06bccaeb9655f2208e73e3882c783cc2413dc51 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Wed, 27 May 2026 17:36:37 -0700 Subject: [PATCH 02/23] Rename project --- ...> configuring-playbook-bridge-rustpush.md} | 12 +- ...uring-playbook-bridge-rustpush.md.license} | 0 group_vars/matrix_servers | 80 +++---- .../defaults/main.yml | 222 ------------------ .../tasks/setup_install.yml | 115 --------- .../tasks/validate_config.yml | 19 -- .../templates/labels.j2 | 52 ---- .../matrix-bridge-rustpush/defaults/main.yml | 222 ++++++++++++++++++ .../tasks/main.yml | 12 +- .../tasks/setup_install.yml | 115 +++++++++ .../tasks/setup_uninstall.yml | 16 +- .../tasks/validate_config.yml | 19 ++ .../templates/Dockerfile.j2 | 0 .../templates/Dockerfile.j2.license | 0 .../templates/config.yaml.j2 | 62 ++--- .../templates/config.yaml.j2.license | 0 .../templates/labels.j2 | 52 ++++ .../templates/labels.j2.license | 0 .../matrix-rustpush-bridge.service.j2} | 36 +-- ...matrix-rustpush-bridge.service.j2.license} | 0 setup.yml | 2 +- 21 files changed, 518 insertions(+), 518 deletions(-) rename docs/{configuring-playbook-bridge-imessage-rustpush.md => configuring-playbook-bridge-rustpush.md} (94%) rename docs/{configuring-playbook-bridge-imessage-rustpush.md.license => configuring-playbook-bridge-rustpush.md.license} (100%) delete mode 100644 roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml delete mode 100644 roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml delete mode 100644 roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml delete mode 100644 roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 create mode 100644 roles/custom/matrix-bridge-rustpush/defaults/main.yml rename roles/custom/{matrix-bridge-imessage-rustpush => matrix-bridge-rustpush}/tasks/main.yml (63%) create mode 100644 roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml rename roles/custom/{matrix-bridge-imessage-rustpush => matrix-bridge-rustpush}/tasks/setup_uninstall.yml (50%) create mode 100644 roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml rename roles/custom/{matrix-bridge-imessage-rustpush => matrix-bridge-rustpush}/templates/Dockerfile.j2 (100%) rename roles/custom/{matrix-bridge-imessage-rustpush => matrix-bridge-rustpush}/templates/Dockerfile.j2.license (100%) rename roles/custom/{matrix-bridge-imessage-rustpush => matrix-bridge-rustpush}/templates/config.yaml.j2 (69%) rename roles/custom/{matrix-bridge-imessage-rustpush => matrix-bridge-rustpush}/templates/config.yaml.j2.license (100%) create mode 100644 roles/custom/matrix-bridge-rustpush/templates/labels.j2 rename roles/custom/{matrix-bridge-imessage-rustpush => matrix-bridge-rustpush}/templates/labels.j2.license (100%) rename roles/custom/{matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 => matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2} (57%) rename roles/custom/{matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2.license => matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2.license} (100%) diff --git a/docs/configuring-playbook-bridge-imessage-rustpush.md b/docs/configuring-playbook-bridge-rustpush.md similarity index 94% rename from docs/configuring-playbook-bridge-imessage-rustpush.md rename to docs/configuring-playbook-bridge-rustpush.md index 3db2e5250..b92c98df0 100644 --- a/docs/configuring-playbook-bridge-imessage-rustpush.md +++ b/docs/configuring-playbook-bridge-rustpush.md @@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2025 MDAD project contributors SPDX-License-Identifier: AGPL-3.0-or-later --> -# Setting up iMessage RustPush bridging (optional) +# Setting up RustPush bridging (optional) Refer the common guide for configuring mautrix bridges: [Setting up a Generic Mautrix Bridge](configuring-playbook-bridge-mautrix-bridges.md) @@ -33,7 +33,7 @@ See [this section](configuring-playbook-bridge-mautrix-bridges.md#set-up-double- To enable the bridge, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file: ```yaml -matrix_imessage_rustpush_enabled: true +matrix_rustpush_bridge_enabled: true ``` ### Backfill (optional) @@ -41,8 +41,8 @@ matrix_imessage_rustpush_enabled: true Backfill is disabled by default because Linux Docker cannot access the macOS `chat.db` file. If you are running on macOS with Full Disk Access, you can enable it: ```yaml -matrix_imessage_rustpush_backfill_enabled: true -matrix_imessage_rustpush_initial_sync_days: 365 +matrix_rustpush_bridge_backfill_enabled: true +matrix_rustpush_bridge_initial_sync_days: 365 ``` ### Extending the configuration @@ -81,7 +81,7 @@ After logging in, the bridge will start receiving iMessages and creating portal ## Troubleshooting -As with all other services, you can find the logs in [systemd-journald](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html) by logging in to the server with SSH and running `journalctl -fu matrix-imessage-rustpush`. +As with all other services, you can find the logs in [systemd-journald](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html) by logging in to the server with SSH and running `journalctl -fu matrix-rustpush-bridge`. ### Increase logging verbosity @@ -89,5 +89,5 @@ The default logging level for this component is `warn`. If you want to increase ```yaml # Valid values: fatal, error, warn, info, debug, trace -matrix_imessage_rustpush_logging_level: 'debug' +matrix_rustpush_bridge_logging_level: 'debug' ``` diff --git a/docs/configuring-playbook-bridge-imessage-rustpush.md.license b/docs/configuring-playbook-bridge-rustpush.md.license similarity index 100% rename from docs/configuring-playbook-bridge-imessage-rustpush.md.license rename to docs/configuring-playbook-bridge-rustpush.md.license diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 9269b15f4..7bdb2e1ac 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -114,7 +114,7 @@ matrix_homeserver_container_extra_arguments_auto: | + (['--mount type=bind,src=' + matrix_mautrix_bluesky_config_path + '/registration.yaml,dst=/matrix-mautrix-bluesky-registration.yaml,ro'] if matrix_mautrix_bluesky_enabled else []) + - (['--mount type=bind,src=' + matrix_imessage_rustpush_config_path + '/registration.yaml,dst=/matrix-imessage-rustpush-registration.yaml,ro'] if matrix_imessage_rustpush_enabled else []) + (['--mount type=bind,src=' + matrix_rustpush_bridge_config_path + '/registration.yaml,dst=/matrix-rustpush-bridge-registration.yaml,ro'] if matrix_rustpush_bridge_enabled else []) + (['--mount type=bind,src=' + matrix_mautrix_discord_config_path + '/registration.yaml,dst=/matrix-mautrix-discord-registration.yaml,ro'] if matrix_mautrix_discord_enabled else []) + @@ -173,7 +173,7 @@ matrix_homeserver_app_service_config_files_auto: | + (['/matrix-mautrix-bluesky-registration.yaml'] if matrix_mautrix_bluesky_enabled else []) + - (['/matrix-imessage-rustpush-registration.yaml'] if matrix_imessage_rustpush_enabled else []) + (['/matrix-rustpush-bridge-registration.yaml'] if matrix_rustpush_bridge_enabled else []) + (['/matrix-mautrix-discord-registration.yaml'] if matrix_mautrix_discord_enabled else []) + @@ -441,11 +441,11 @@ devture_systemd_service_manager_services_list_auto: | }] if matrix_mautrix_bluesky_enabled else []) + ([{ - 'name': 'matrix-imessage-rustpush.service', + 'name': 'matrix-rustpush-bridge.service', 'priority': 2000, - 'restart_necessary': (matrix_imessage_rustpush_restart_necessary | bool), - 'groups': ['matrix', 'bridges', 'imessage-rustpush'], - }] if matrix_imessage_rustpush_enabled else []) + 'restart_necessary': (matrix_rustpush_bridge_restart_necessary | bool), + 'groups': ['matrix', 'bridges', 'matrix-rustpush-bridge'], + }] if matrix_rustpush_bridge_enabled else []) + ([{ 'name': 'matrix-mautrix-discord.service', @@ -1483,71 +1483,71 @@ matrix_mautrix_bluesky_database_password: "{{ (matrix_homeserver_generic_secret_ ###################################################################### # -# matrix-bridge-imessage-rustpush +# matrix-bridge-rustpush # ###################################################################### # We don't enable bridges by default. -matrix_imessage_rustpush_enabled: false +matrix_rustpush_bridge_enabled: false -matrix_imessage_rustpush_systemd_required_services_list_auto: | +matrix_rustpush_bridge_systemd_required_services_list_auto: | {{ matrix_addons_homeserver_systemd_services_list + - ([postgres_identifier ~ '.service'] if (postgres_enabled and matrix_imessage_rustpush_database_hostname == postgres_connection_hostname) else []) + ([postgres_identifier ~ '.service'] if (postgres_enabled and matrix_rustpush_bridge_database_hostname == postgres_connection_hostname) else []) }} -matrix_imessage_rustpush_container_network: "{{ matrix_addons_container_network }}" +matrix_rustpush_bridge_container_network: "{{ matrix_addons_container_network }}" -matrix_imessage_rustpush_container_additional_networks_auto: |- +matrix_rustpush_bridge_container_additional_networks_auto: |- {{ ( ([] if matrix_addons_homeserver_container_network == '' else [matrix_addons_homeserver_container_network]) + - ([postgres_container_network] if (postgres_enabled and matrix_imessage_rustpush_database_hostname == postgres_connection_hostname and matrix_imessage_rustpush_container_network != postgres_container_network) else []) + ([postgres_container_network] if (postgres_enabled and matrix_rustpush_bridge_database_hostname == postgres_connection_hostname and matrix_rustpush_bridge_container_network != postgres_container_network) else []) + - ([matrix_playbook_reverse_proxyable_services_additional_network] if matrix_playbook_reverse_proxyable_services_additional_network and matrix_imessage_rustpush_container_labels_traefik_enabled else []) + ([matrix_playbook_reverse_proxyable_services_additional_network] if matrix_playbook_reverse_proxyable_services_additional_network and matrix_rustpush_bridge_container_labels_traefik_enabled else []) ) | unique }} -matrix_imessage_rustpush_container_labels_traefik_enabled: "{{ matrix_playbook_reverse_proxy_type in ['playbook-managed-traefik', 'other-traefik-container'] }}" -matrix_imessage_rustpush_container_labels_traefik_docker_network: "{{ matrix_playbook_reverse_proxyable_services_additional_network }}" -matrix_imessage_rustpush_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" -matrix_imessage_rustpush_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" +matrix_rustpush_bridge_container_labels_traefik_enabled: "{{ matrix_playbook_reverse_proxy_type in ['playbook-managed-traefik', 'other-traefik-container'] }}" +matrix_rustpush_bridge_container_labels_traefik_docker_network: "{{ matrix_playbook_reverse_proxyable_services_additional_network }}" +matrix_rustpush_bridge_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" +matrix_rustpush_bridge_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" -matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_enabled: "{{ matrix_metrics_exposure_http_basic_auth_enabled }}" -matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_users: "{{ matrix_metrics_exposure_http_basic_auth_users }}" +matrix_rustpush_bridge_container_labels_metrics_middleware_basic_auth_enabled: "{{ matrix_metrics_exposure_http_basic_auth_enabled }}" +matrix_rustpush_bridge_container_labels_metrics_middleware_basic_auth_users: "{{ matrix_metrics_exposure_http_basic_auth_users }}" -matrix_imessage_rustpush_appservice_token: "{{ (matrix_homeserver_generic_secret_key + ':imsg.as.token') | hash('sha512') | to_uuid }}" +matrix_rustpush_bridge_appservice_token: "{{ (matrix_homeserver_generic_secret_key + ':imsg.as.token') | hash('sha512') | to_uuid }}" -matrix_imessage_rustpush_homeserver_address: "{{ matrix_addons_homeserver_client_api_url }}" -matrix_imessage_rustpush_homeserver_token: "{{ (matrix_homeserver_generic_secret_key + ':imsg.hs.token') | hash('sha512') | to_uuid }}" +matrix_rustpush_bridge_homeserver_address: "{{ matrix_addons_homeserver_client_api_url }}" +matrix_rustpush_bridge_homeserver_token: "{{ (matrix_homeserver_generic_secret_key + ':imsg.hs.token') | hash('sha512') | to_uuid }}" -matrix_imessage_rustpush_homeserver_async_media: "{{ matrix_homeserver_implementation in ['synapse'] }}" +matrix_rustpush_bridge_homeserver_async_media: "{{ matrix_homeserver_implementation in ['synapse'] }}" -matrix_imessage_rustpush_provisioning_shared_secret: "{{ (matrix_homeserver_generic_secret_key + ':mau.imsg.prov') | hash('sha512') | to_uuid }}" +matrix_rustpush_bridge_provisioning_shared_secret: "{{ (matrix_homeserver_generic_secret_key + ':mau.imsg.prov') | hash('sha512') | to_uuid }}" -matrix_imessage_rustpush_double_puppet_secrets_auto: |- +matrix_rustpush_bridge_double_puppet_secrets_auto: |- {{ ({ - matrix_imessage_rustpush_homeserver_domain: ("as_token:" + matrix_appservice_double_puppet_registration_as_token) + matrix_rustpush_bridge_homeserver_domain: ("as_token:" + matrix_appservice_double_puppet_registration_as_token) }) if matrix_appservice_double_puppet_enabled else {} }} -matrix_imessage_rustpush_metrics_enabled: "{{ prometheus_enabled or matrix_metrics_exposure_enabled }}" +matrix_rustpush_bridge_metrics_enabled: "{{ prometheus_enabled or matrix_metrics_exposure_enabled }}" -matrix_imessage_rustpush_metrics_proxying_enabled: "{{ matrix_imessage_rustpush_metrics_enabled and matrix_metrics_exposure_enabled }}" -matrix_imessage_rustpush_metrics_proxying_hostname: "{{ matrix_metrics_exposure_hostname }}" -matrix_imessage_rustpush_metrics_proxying_path_prefix: "{{ matrix_metrics_exposure_path_prefix }}/imessage-rustpush" +matrix_rustpush_bridge_metrics_proxying_enabled: "{{ matrix_rustpush_bridge_metrics_enabled and matrix_metrics_exposure_enabled }}" +matrix_rustpush_bridge_metrics_proxying_hostname: "{{ matrix_metrics_exposure_hostname }}" +matrix_rustpush_bridge_metrics_proxying_path_prefix: "{{ matrix_metrics_exposure_path_prefix }}/rustpush-bridge" -matrix_imessage_rustpush_database_hostname: "{{ postgres_connection_hostname if postgres_enabled else '' }}" -matrix_imessage_rustpush_database_password: "{{ (matrix_homeserver_generic_secret_key + ':mau.imsg.db') | hash('sha512') | to_uuid if postgres_enabled else '' }}" +matrix_rustpush_bridge_database_hostname: "{{ postgres_connection_hostname if postgres_enabled else '' }}" +matrix_rustpush_bridge_database_password: "{{ (matrix_homeserver_generic_secret_key + ':mau.imsg.db') | hash('sha512') | to_uuid if postgres_enabled else '' }}" ###################################################################### # -# /matrix-bridge-imessage-rustpush +# /matrix-bridge-rustpush # ###################################################################### @@ -4135,10 +4135,10 @@ postgres_managed_databases_auto: | }] if (matrix_mautrix_bluesky_enabled and matrix_mautrix_bluesky_database_engine == 'postgres' and matrix_mautrix_bluesky_database_hostname == postgres_connection_hostname) else []) + ([{ - 'name': matrix_imessage_rustpush_database_name, - 'username': matrix_imessage_rustpush_database_username, - 'password': matrix_imessage_rustpush_database_password, - }] if (matrix_imessage_rustpush_enabled and matrix_imessage_rustpush_database_engine == 'postgres' and matrix_imessage_rustpush_database_hostname == postgres_connection_hostname) else []) + 'name': matrix_rustpush_bridge_database_name, + 'username': matrix_rustpush_bridge_database_username, + 'password': matrix_rustpush_bridge_database_password, + }] if (matrix_rustpush_bridge_enabled and matrix_rustpush_bridge_database_engine == 'postgres' and matrix_rustpush_bridge_database_hostname == postgres_connection_hostname) else []) + ([{ 'name': matrix_mautrix_googlechat_database_name, @@ -5081,9 +5081,9 @@ matrix_ketesa_config_asManagedUsers_auto: | ] if matrix_mautrix_bluesky_enabled else []) + ([ - '^@'+(matrix_imessage_rustpush_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', + '^@'+(matrix_rustpush_bridge_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', '^@imessage_[a-zA-Z0-9_.+-]+:'+(matrix_domain | regex_escape)+'$', - ] if matrix_imessage_rustpush_enabled else []) + ] if matrix_rustpush_bridge_enabled else []) + ([ '^@'+(matrix_mautrix_discord_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', diff --git a/roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml deleted file mode 100644 index c0ae1cb31..000000000 --- a/roles/custom/matrix-bridge-imessage-rustpush/defaults/main.yml +++ /dev/null @@ -1,222 +0,0 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- -# matrix-bridge-imessage-rustpush is a Matrix <-> iMessage bridge using RustPush -# Project source code URL: https://github.com/lrhodin/imessage - -matrix_imessage_rustpush_enabled: true - -# No upstream Docker image exists; self-build is always required. -matrix_imessage_rustpush_container_image_self_build: true -matrix_imessage_rustpush_container_image_self_build_repo: "https://github.com/lrhodin/imessage.git" -matrix_imessage_rustpush_container_image_self_build_repo_version: "{{ 'main' if matrix_imessage_rustpush_version == 'latest' else matrix_imessage_rustpush_version }}" - -matrix_imessage_rustpush_version: latest -matrix_imessage_rustpush_docker_image: "{{ matrix_imessage_rustpush_docker_image_registry_prefix }}lrhodin/imessage:{{ matrix_imessage_rustpush_version }}" -matrix_imessage_rustpush_docker_image_registry_prefix: "localhost/" -matrix_imessage_rustpush_docker_image_force_pull: "{{ matrix_imessage_rustpush_docker_image.endswith(':latest') }}" - -matrix_imessage_rustpush_base_path: "{{ matrix_base_data_path }}/imessage-rustpush" -matrix_imessage_rustpush_config_path: "{{ matrix_imessage_rustpush_base_path }}/config" -matrix_imessage_rustpush_data_path: "{{ matrix_imessage_rustpush_base_path }}/data" -matrix_imessage_rustpush_docker_src_files_path: "{{ matrix_imessage_rustpush_base_path }}/docker-src" - -matrix_imessage_rustpush_homeserver_address: "" -# Whether asynchronous uploads via MSC2246 should be enabled for media. -matrix_imessage_rustpush_homeserver_async_media: false -matrix_imessage_rustpush_homeserver_domain: '{{ matrix_domain }}' -matrix_imessage_rustpush_appservice_address: 'http://matrix-imessage-rustpush:8081' - -matrix_imessage_rustpush_msc4190_enabled: "{{ matrix_bridges_msc4190_enabled }}" -matrix_imessage_rustpush_self_sign_enabled: "{{ matrix_bridges_self_sign_enabled }}" - -# A public address that external services can use to reach this appservice. -matrix_imessage_rustpush_appservice_public_address: '' - -# Displayname template for iMessage contacts. -# Available variables: {{.FirstName}}, {{.LastName}}, {{.Nickname}}, -# {{.Phone}}, {{.Email}}, {{.ID}} -matrix_imessage_rustpush_network_displayname_template: "{% raw %}{{if .FirstName}}{{.FirstName}}{{if .LastName}} {{.LastName}}{{end}}{{else if .Nickname}}{{.Nickname}}{{else if .Phone}}{{.Phone}}{{else if .Email}}{{.Email}}{{else}}{{.ID}}{{end}}{% endraw %}" - -matrix_imessage_rustpush_bridge_command_prefix: "!imessage" - -matrix_imessage_rustpush_bridge_permissions: | - {{ - {matrix_imessage_rustpush_homeserver_domain: 'user'} - | combine({matrix_admin: 'admin'} if matrix_admin else {}) - }} - -matrix_imessage_rustpush_container_network: "" - -matrix_imessage_rustpush_container_additional_networks: "{{ matrix_imessage_rustpush_container_additional_networks_auto + matrix_imessage_rustpush_container_additional_networks_custom }}" -matrix_imessage_rustpush_container_additional_networks_auto: [] -matrix_imessage_rustpush_container_additional_networks_custom: [] - -# matrix_imessage_rustpush_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container. -# See `../templates/labels.j2` for details. -# -# To inject your own other container labels, see `matrix_imessage_rustpush_container_labels_additional_labels`. -matrix_imessage_rustpush_container_labels_traefik_enabled: true -matrix_imessage_rustpush_container_labels_traefik_docker_network: "{{ matrix_imessage_rustpush_container_network }}" -matrix_imessage_rustpush_container_labels_traefik_entrypoints: web-secure -matrix_imessage_rustpush_container_labels_traefik_tls_certResolver: default # noqa var-naming - -# Controls whether labels will be added that expose metrics -matrix_imessage_rustpush_container_labels_metrics_enabled: "{{ matrix_imessage_rustpush_metrics_enabled and matrix_imessage_rustpush_metrics_proxying_enabled }}" -matrix_imessage_rustpush_container_labels_metrics_traefik_rule: "Host(`{{ matrix_imessage_rustpush_metrics_proxying_hostname }}`) && PathPrefix(`{{ matrix_imessage_rustpush_metrics_proxying_path_prefix }}`)" -matrix_imessage_rustpush_container_labels_metrics_traefik_priority: 0 -matrix_imessage_rustpush_container_labels_metrics_traefik_entrypoints: "{{ matrix_imessage_rustpush_container_labels_traefik_entrypoints }}" -matrix_imessage_rustpush_container_labels_metrics_traefik_tls: "{{ matrix_imessage_rustpush_container_labels_metrics_traefik_entrypoints != 'web' }}" -matrix_imessage_rustpush_container_labels_metrics_traefik_tls_certResolver: "{{ matrix_imessage_rustpush_container_labels_traefik_tls_certResolver }}" # noqa var-naming -matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_enabled: false -# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users -matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_users: '' - -# matrix_imessage_rustpush_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file. -# See `../templates/labels.j2` for details. -# -# Example: -# matrix_imessage_rustpush_container_labels_additional_labels: | -# my.label=1 -# another.label="here" -matrix_imessage_rustpush_container_labels_additional_labels: '' - -# A list of extra arguments to pass to the container -matrix_imessage_rustpush_container_extra_arguments: [] - -# List of systemd services that matrix-imessage-rustpush.service depends on. -matrix_imessage_rustpush_systemd_required_services_list: "{{ matrix_imessage_rustpush_systemd_required_services_list_default + matrix_imessage_rustpush_systemd_required_services_list_auto + matrix_imessage_rustpush_systemd_required_services_list_custom }}" -matrix_imessage_rustpush_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" -matrix_imessage_rustpush_systemd_required_services_list_auto: [] -matrix_imessage_rustpush_systemd_required_services_list_custom: [] - -# List of systemd services that matrix-imessage-rustpush.service wants -matrix_imessage_rustpush_systemd_wanted_services_list: [] - -matrix_imessage_rustpush_appservice_token: '' -matrix_imessage_rustpush_homeserver_token: '' - -# Whether or not created rooms should have federation enabled. -# If false, created portal rooms will never be federated. -matrix_imessage_rustpush_matrix_federate_rooms: true - -# Database-related configuration fields. -# -# To use Postgres: -# - adjust your database credentials via the `matrix_imessage_rustpush_postgres_*` variables -matrix_imessage_rustpush_database_engine: 'postgres' - -matrix_imessage_rustpush_database_username: 'matrix_imessage_rustpush' -matrix_imessage_rustpush_database_password: 'some-password' -matrix_imessage_rustpush_database_hostname: '' -matrix_imessage_rustpush_database_port: 5432 -matrix_imessage_rustpush_database_name: 'matrix_imessage_rustpush' -matrix_imessage_rustpush_database_sslmode: disable - -matrix_imessage_rustpush_database_connection_string: 'postgres://{{ matrix_imessage_rustpush_database_username }}:{{ matrix_imessage_rustpush_database_password }}@{{ matrix_imessage_rustpush_database_hostname }}:{{ matrix_imessage_rustpush_database_port }}/{{ matrix_imessage_rustpush_database_name }}?sslmode={{ matrix_imessage_rustpush_database_sslmode }}' - -matrix_imessage_rustpush_database_uri: "{{ - { - 'postgres': matrix_imessage_rustpush_database_connection_string, - }[matrix_imessage_rustpush_database_engine] -}}" - -matrix_imessage_rustpush_double_puppet_secrets: "{{ matrix_imessage_rustpush_double_puppet_secrets_auto | combine(matrix_imessage_rustpush_double_puppet_secrets_custom) }}" -matrix_imessage_rustpush_double_puppet_secrets_auto: {} -matrix_imessage_rustpush_double_puppet_secrets_custom: {} - -matrix_imessage_rustpush_appservice_bot_username: imessagebot -matrix_imessage_rustpush_appservice_bot_displayname: iMessage bridge bot -matrix_imessage_rustpush_appservice_bot_avatar: '' - -# Backfill is disabled by default because Linux Docker cannot access chat.db. -# On macOS with Full Disk Access, this can be set to true. -matrix_imessage_rustpush_backfill_enabled: false -# Maximum number of messages to backfill in empty rooms -matrix_imessage_rustpush_backfill_max_initial_messages: 50 - -# Maximum number of missed messages to backfill after bridge restarts -matrix_imessage_rustpush_backfill_max_catchup_messages: 500 - -# How many days back to look for chats during initial sync. -# Default in upstream is 365 (1 year). Set to 0 to disable. -matrix_imessage_rustpush_initial_sync_days: 0 - -# Shared secret for authentication of provisioning API requests. -# If set to "disable", the provisioning API will be disabled. -matrix_imessage_rustpush_provisioning_shared_secret: disable - -# Minimum severity of journal log messages. -# Valid values: fatal, error, warn, info, debug, trace -matrix_imessage_rustpush_logging_level: 'warn' - -# Whether or not metrics endpoint should be enabled. -# Enabling them is usually enough for a local (in-container) Prometheus to consume them. -# If metrics need to be consumed by another (external) Prometheus server, consider exposing them via `matrix_imessage_rustpush_metrics_proxying_enabled`. -matrix_imessage_rustpush_metrics_enabled: false - -# Controls whether metrics should be exposed on a public URL. -matrix_imessage_rustpush_metrics_proxying_enabled: false -matrix_imessage_rustpush_metrics_proxying_hostname: '' -matrix_imessage_rustpush_metrics_proxying_path_prefix: '' - -# Default configuration template which covers the generic use case. -# You can customize it by controlling the various variables inside it. -# -# For a more advanced customization, you can extend the default (see `matrix_imessage_rustpush_configuration_extension_yaml`) -# or completely replace this variable with your own template. -matrix_imessage_rustpush_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}" - -matrix_imessage_rustpush_configuration_extension_yaml: | - # Your custom YAML configuration goes here. - # This configuration extends the default starting configuration (`matrix_imessage_rustpush_configuration_yaml`). - # - # You can override individual variables from the default configuration, or introduce new ones. - # - # If you need something more special, you can take full control by - # completely redefining `matrix_imessage_rustpush_configuration_yaml`. - -matrix_imessage_rustpush_configuration_extension: "{{ matrix_imessage_rustpush_configuration_extension_yaml | from_yaml if matrix_imessage_rustpush_configuration_extension_yaml | from_yaml is mapping else {} }}" - -# Holds the final configuration (a combination of the default and its extension). -# You most likely don't need to touch this variable. Instead, see `matrix_imessage_rustpush_configuration_yaml`. -matrix_imessage_rustpush_configuration: "{{ matrix_imessage_rustpush_configuration_yaml | from_yaml | combine(matrix_imessage_rustpush_configuration_extension, recursive=True) }}" - -matrix_imessage_rustpush_registration_yaml: | - id: imessage-rustpush - as_token: "{{ matrix_imessage_rustpush_appservice_token }}" - hs_token: "{{ matrix_imessage_rustpush_homeserver_token }}" - namespaces: - users: - - exclusive: true - regex: '^@imessage_.+:{{ matrix_imessage_rustpush_homeserver_domain | regex_escape }}$' - - exclusive: true - regex: '^@{{ matrix_imessage_rustpush_appservice_bot_username | regex_escape }}:{{ matrix_imessage_rustpush_homeserver_domain | regex_escape }}$' - url: {{ matrix_imessage_rustpush_appservice_address }} - sender_localpart: _bot_{{ matrix_imessage_rustpush_appservice_bot_username }} - rate_limited: false - de.sorunome.msc2409.push_ephemeral: true - receive_ephemeral: true - io.element.msc4190: {{ matrix_imessage_rustpush_msc4190_enabled | to_json }} - -matrix_imessage_rustpush_registration: "{{ matrix_imessage_rustpush_registration_yaml | from_yaml }}" - -# Enable End-to-bridge encryption -matrix_imessage_rustpush_bridge_encryption_allow: "{{ matrix_bridges_encryption_enabled }}" -matrix_imessage_rustpush_bridge_encryption_default: "{{ matrix_bridges_encryption_default }}" -matrix_imessage_rustpush_bridge_encryption_require: false -matrix_imessage_rustpush_bridge_encryption_appservice: false -matrix_imessage_rustpush_bridge_encryption_key_sharing_allow: "{{ matrix_imessage_rustpush_bridge_encryption_allow }}" -matrix_imessage_rustpush_bridge_encryption_pickle_key: mautrix.bridge.e2ee - -# matrix_imessage_rustpush_restart_necessary controls whether the service -# will be restarted (when true) or merely started (when false) by the -# systemd service manager role (when conditional restart is enabled). -# -# This value is automatically computed during installation based on whether -# any configuration files, the systemd service file, or the container image changed. -# The default of `false` means "no restart needed" — appropriate when the role's -# installation tasks haven't run (e.g., due to --tags skipping them). -matrix_imessage_rustpush_restart_necessary: false diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml b/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml deleted file mode 100644 index 0fe6e7285..000000000 --- a/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_install.yml +++ /dev/null @@ -1,115 +0,0 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- - -- name: Ensure iMessage RustPush paths exist - ansible.builtin.file: - path: "{{ item.path }}" - state: directory - mode: 0750 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - with_items: - - {path: "{{ matrix_imessage_rustpush_base_path }}", when: true} - - {path: "{{ matrix_imessage_rustpush_config_path }}", when: true} - - {path: "{{ matrix_imessage_rustpush_data_path }}", when: true} - - {path: "{{ matrix_imessage_rustpush_docker_src_files_path }}", when: "{{ matrix_imessage_rustpush_container_image_self_build }}"} - when: item.when | bool - -- name: Ensure iMessage RustPush repository is present on self-build - ansible.builtin.git: - repo: "{{ matrix_imessage_rustpush_container_image_self_build_repo }}" - version: "{{ matrix_imessage_rustpush_container_image_self_build_repo_version }}" - dest: "{{ matrix_imessage_rustpush_docker_src_files_path }}" - force: "yes" - become: true - become_user: "{{ matrix_user_name }}" - register: matrix_imessage_rustpush_git_pull_results - when: "matrix_imessage_rustpush_enabled | bool and matrix_imessage_rustpush_container_image_self_build" - -- name: Ensure iMessage RustPush Dockerfile is installed - ansible.builtin.template: - src: "{{ role_path }}/templates/Dockerfile.j2" - dest: "{{ matrix_imessage_rustpush_docker_src_files_path }}/Dockerfile" - mode: 0640 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - when: "matrix_imessage_rustpush_enabled | bool and matrix_imessage_rustpush_container_image_self_build | bool" - -- name: Ensure iMessage RustPush Docker image is built - community.docker.docker_image: - name: "{{ matrix_imessage_rustpush_docker_image }}" - source: build - force_source: "{{ matrix_imessage_rustpush_git_pull_results.changed if matrix_imessage_rustpush_git_pull_results is defined else true }}" - build: - dockerfile: Dockerfile - path: "{{ matrix_imessage_rustpush_docker_src_files_path }}" - pull: true - register: matrix_imessage_rustpush_container_image_build_result - when: "matrix_imessage_rustpush_enabled | bool and matrix_imessage_rustpush_container_image_self_build | bool" - -- name: Ensure iMessage RustPush container image is pulled - community.docker.docker_image: - name: "{{ matrix_imessage_rustpush_docker_image }}" - source: pull - force_source: "{{ matrix_imessage_rustpush_container_image_force_pull if matrix_imessage_rustpush_container_image_force_pull is defined else true }}" - register: matrix_imessage_rustpush_container_image_pull_result - when: "matrix_imessage_rustpush_enabled | bool and not matrix_imessage_rustpush_container_image_self_build | bool" - ignore_errors: "{{ ansible_check_mode }}" - -- name: Ensure imessage-rustpush config.yaml installed - ansible.builtin.copy: - content: "{{ matrix_imessage_rustpush_configuration | to_nice_yaml(indent=2, width=999999) }}" - dest: "{{ matrix_imessage_rustpush_config_path }}/config.yaml" - mode: 0644 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - register: matrix_imessage_rustpush_config_result - -- name: Ensure imessage-rustpush registration.yaml installed - ansible.builtin.copy: - content: "{{ matrix_imessage_rustpush_registration | to_nice_yaml(indent=2, width=999999) }}" - dest: "{{ matrix_imessage_rustpush_config_path }}/registration.yaml" - mode: 0644 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - register: matrix_imessage_rustpush_registration_result - -- name: Ensure imessage-rustpush support files installed - ansible.builtin.template: - src: "{{ role_path }}/templates/{{ item }}.j2" - dest: "{{ matrix_imessage_rustpush_base_path }}/{{ item }}" - mode: 0640 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - with_items: - - labels - register: matrix_imessage_rustpush_support_files_result - -- name: Ensure matrix-imessage-rustpush container network is created - community.general.docker_network: - enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}" - name: "{{ matrix_imessage_rustpush_container_network }}" - driver: bridge - driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}" - -- name: Ensure matrix-imessage-rustpush.service installed - ansible.builtin.template: - src: "{{ role_path }}/templates/systemd/matrix-imessage-rustpush.service.j2" - dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-imessage-rustpush.service" - mode: 0644 - register: matrix_imessage_rustpush_systemd_service_result - -- name: Determine whether matrix-imessage-rustpush needs a restart - ansible.builtin.set_fact: - matrix_imessage_rustpush_restart_necessary: >- - {{ - matrix_imessage_rustpush_config_result.changed | default(false) - or matrix_imessage_rustpush_registration_result.changed | default(false) - or matrix_imessage_rustpush_support_files_result.changed | default(false) - or matrix_imessage_rustpush_systemd_service_result.changed | default(false) - or matrix_imessage_rustpush_container_image_pull_result.changed | default(false) - or matrix_imessage_rustpush_container_image_build_result.changed | default(false) - }} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml b/roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml deleted file mode 100644 index d2c846c14..000000000 --- a/roles/custom/matrix-bridge-imessage-rustpush/tasks/validate_config.yml +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- - -- name: Fail if required iMessage RustPush settings not defined - ansible.builtin.fail: - msg: >- - You need to define a required configuration setting (`{{ item.name }}`). - when: "item.when | bool and lookup('vars', item.name, default='') | string | length == 0" - with_items: - - {'name': 'matrix_imessage_rustpush_appservice_token', when: true} - - {'name': 'matrix_imessage_rustpush_homeserver_address', when: true} - - {'name': 'matrix_imessage_rustpush_homeserver_token', when: true} - - {'name': 'matrix_imessage_rustpush_database_hostname', when: "{{ matrix_imessage_rustpush_database_engine == 'postgres' }}"} - - {'name': 'matrix_imessage_rustpush_container_network', when: true} - - {'name': 'matrix_imessage_rustpush_metrics_proxying_hostname', when: "{{ matrix_imessage_rustpush_metrics_proxying_enabled }}"} - - {'name': 'matrix_imessage_rustpush_metrics_proxying_path_prefix', when: "{{ matrix_imessage_rustpush_metrics_proxying_enabled }}"} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 b/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 deleted file mode 100644 index 4021967dd..000000000 --- a/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2 +++ /dev/null @@ -1,52 +0,0 @@ -{# -SPDX-FileCopyrightText: 2025 MDAD project contributors - -SPDX-License-Identifier: AGPL-3.0-or-later -#} - -{% if matrix_imessage_rustpush_container_labels_traefik_enabled %} -traefik.enable=true - -{% if matrix_imessage_rustpush_container_labels_traefik_docker_network %} -traefik.docker.network={{ matrix_imessage_rustpush_container_labels_traefik_docker_network }} -{% endif %} - -traefik.http.services.matrix-imessage-rustpush-metrics.loadbalancer.server.port=8000 - -{% if matrix_imessage_rustpush_container_labels_metrics_enabled %} -############################################################ -# # -# Metrics # -# # -############################################################ - -{% if matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_enabled %} -traefik.http.middlewares.matrix-imessage-rustpush-metrics-basic-auth.basicauth.users={{ matrix_imessage_rustpush_container_labels_metrics_middleware_basic_auth_users }} -traefik.http.routers.matrix-imessage-rustpush-metrics.middlewares=matrix-imessage-rustpush-metrics-basic-auth -{% endif %} - -traefik.http.routers.matrix-imessage-rustpush-metrics.rule={{ matrix_imessage_rustpush_container_labels_metrics_traefik_rule }} - -{% if matrix_imessage_rustpush_container_labels_metrics_traefik_priority | int > 0 %} -traefik.http.routers.matrix-imessage-rustpush-metrics.priority={{ matrix_imessage_rustpush_container_labels_metrics_traefik_priority }} -{% endif %} - -traefik.http.routers.matrix-imessage-rustpush-metrics.service=matrix-imessage-rustpush-metrics -traefik.http.routers.matrix-imessage-rustpush-metrics.entrypoints={{ matrix_imessage_rustpush_container_labels_metrics_traefik_entrypoints }} - -traefik.http.routers.matrix-imessage-rustpush-metrics.tls={{ matrix_imessage_rustpush_container_labels_metrics_traefik_tls | to_json }} -{% if matrix_imessage_rustpush_container_labels_metrics_traefik_tls %} -traefik.http.routers.matrix-imessage-rustpush-metrics.tls.certResolver={{ matrix_imessage_rustpush_container_labels_metrics_traefik_tls_certResolver }} -{% endif %} - -############################################################ -# # -# /Metrics # -# # -############################################################ -{% endif %} - - -{% endif %} - -{{ matrix_imessage_rustpush_container_labels_additional_labels }} diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml new file mode 100644 index 000000000..ebc292793 --- /dev/null +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -0,0 +1,222 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- +# matrix-bridge-rustpush is a Matrix <-> iMessage bridge using RustPush +# Project source code URL: https://github.com/lrhodin/imessage + +matrix_rustpush_bridge_enabled: true + +# No upstream Docker image exists; self-build is always required. +matrix_rustpush_bridge_container_image_self_build: true +matrix_rustpush_bridge_container_image_self_build_repo: "https://github.com/lrhodin/imessage.git" +matrix_rustpush_bridge_container_image_self_build_repo_version: "{{ 'main' if matrix_rustpush_bridge_version == 'latest' else matrix_rustpush_bridge_version }}" + +matrix_rustpush_bridge_version: latest +matrix_rustpush_bridge_docker_image: "{{ matrix_rustpush_bridge_docker_image_registry_prefix }}lrhodin/imessage:{{ matrix_rustpush_bridge_version }}" +matrix_rustpush_bridge_docker_image_registry_prefix: "localhost/" +matrix_rustpush_bridge_docker_image_force_pull: "{{ matrix_rustpush_bridge_docker_image.endswith(':latest') }}" + +matrix_rustpush_bridge_base_path: "{{ matrix_base_data_path }}/rustpush-bridge" +matrix_rustpush_bridge_config_path: "{{ matrix_rustpush_bridge_base_path }}/config" +matrix_rustpush_bridge_data_path: "{{ matrix_rustpush_bridge_base_path }}/data" +matrix_rustpush_bridge_docker_src_files_path: "{{ matrix_rustpush_bridge_base_path }}/docker-src" + +matrix_rustpush_bridge_homeserver_address: "" +# Whether asynchronous uploads via MSC2246 should be enabled for media. +matrix_rustpush_bridge_homeserver_async_media: false +matrix_rustpush_bridge_homeserver_domain: '{{ matrix_domain }}' +matrix_rustpush_bridge_appservice_address: 'http://matrix-rustpush-bridge:8081' + +matrix_rustpush_bridge_msc4190_enabled: "{{ matrix_bridges_msc4190_enabled }}" +matrix_rustpush_bridge_self_sign_enabled: "{{ matrix_bridges_self_sign_enabled }}" + +# A public address that external services can use to reach this appservice. +matrix_rustpush_bridge_appservice_public_address: '' + +# Displayname template for iMessage contacts. +# Available variables: {{.FirstName}}, {{.LastName}}, {{.Nickname}}, +# {{.Phone}}, {{.Email}}, {{.ID}} +matrix_rustpush_bridge_network_displayname_template: "{% raw %}{{if .FirstName}}{{.FirstName}}{{if .LastName}} {{.LastName}}{{end}}{{else if .Nickname}}{{.Nickname}}{{else if .Phone}}{{.Phone}}{{else if .Email}}{{.Email}}{{else}}{{.ID}}{{end}}{% endraw %}" + +matrix_rustpush_bridge_bridge_command_prefix: "!imessage" + +matrix_rustpush_bridge_bridge_permissions: | + {{ + {matrix_rustpush_bridge_homeserver_domain: 'user'} + | combine({matrix_admin: 'admin'} if matrix_admin else {}) + }} + +matrix_rustpush_bridge_container_network: "" + +matrix_rustpush_bridge_container_additional_networks: "{{ matrix_rustpush_bridge_container_additional_networks_auto + matrix_rustpush_bridge_container_additional_networks_custom }}" +matrix_rustpush_bridge_container_additional_networks_auto: [] +matrix_rustpush_bridge_container_additional_networks_custom: [] + +# matrix_rustpush_bridge_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container. +# See `../templates/labels.j2` for details. +# +# To inject your own other container labels, see `matrix_rustpush_bridge_container_labels_additional_labels`. +matrix_rustpush_bridge_container_labels_traefik_enabled: true +matrix_rustpush_bridge_container_labels_traefik_docker_network: "{{ matrix_rustpush_bridge_container_network }}" +matrix_rustpush_bridge_container_labels_traefik_entrypoints: web-secure +matrix_rustpush_bridge_container_labels_traefik_tls_certResolver: default # noqa var-naming + +# Controls whether labels will be added that expose metrics +matrix_rustpush_bridge_container_labels_metrics_enabled: "{{ matrix_rustpush_bridge_metrics_enabled and matrix_rustpush_bridge_metrics_proxying_enabled }}" +matrix_rustpush_bridge_container_labels_metrics_traefik_rule: "Host(`{{ matrix_rustpush_bridge_metrics_proxying_hostname }}`) && PathPrefix(`{{ matrix_rustpush_bridge_metrics_proxying_path_prefix }}`)" +matrix_rustpush_bridge_container_labels_metrics_traefik_priority: 0 +matrix_rustpush_bridge_container_labels_metrics_traefik_entrypoints: "{{ matrix_rustpush_bridge_container_labels_traefik_entrypoints }}" +matrix_rustpush_bridge_container_labels_metrics_traefik_tls: "{{ matrix_rustpush_bridge_container_labels_metrics_traefik_entrypoints != 'web' }}" +matrix_rustpush_bridge_container_labels_metrics_traefik_tls_certResolver: "{{ matrix_rustpush_bridge_container_labels_traefik_tls_certResolver }}" # noqa var-naming +matrix_rustpush_bridge_container_labels_metrics_middleware_basic_auth_enabled: false +# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users +matrix_rustpush_bridge_container_labels_metrics_middleware_basic_auth_users: '' + +# matrix_rustpush_bridge_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file. +# See `../templates/labels.j2` for details. +# +# Example: +# matrix_rustpush_bridge_container_labels_additional_labels: | +# my.label=1 +# another.label="here" +matrix_rustpush_bridge_container_labels_additional_labels: '' + +# A list of extra arguments to pass to the container +matrix_rustpush_bridge_container_extra_arguments: [] + +# List of systemd services that matrix-rustpush-bridge.service depends on. +matrix_rustpush_bridge_systemd_required_services_list: "{{ matrix_rustpush_bridge_systemd_required_services_list_default + matrix_rustpush_bridge_systemd_required_services_list_auto + matrix_rustpush_bridge_systemd_required_services_list_custom }}" +matrix_rustpush_bridge_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" +matrix_rustpush_bridge_systemd_required_services_list_auto: [] +matrix_rustpush_bridge_systemd_required_services_list_custom: [] + +# List of systemd services that matrix-rustpush-bridge.service wants +matrix_rustpush_bridge_systemd_wanted_services_list: [] + +matrix_rustpush_bridge_appservice_token: '' +matrix_rustpush_bridge_homeserver_token: '' + +# Whether or not created rooms should have federation enabled. +# If false, created portal rooms will never be federated. +matrix_rustpush_bridge_matrix_federate_rooms: true + +# Database-related configuration fields. +# +# To use Postgres: +# - adjust your database credentials via the `matrix_rustpush_bridge_postgres_*` variables +matrix_rustpush_bridge_database_engine: 'postgres' + +matrix_rustpush_bridge_database_username: 'matrix_rustpush_bridge' +matrix_rustpush_bridge_database_password: 'some-password' +matrix_rustpush_bridge_database_hostname: '' +matrix_rustpush_bridge_database_port: 5432 +matrix_rustpush_bridge_database_name: 'matrix_rustpush_bridge' +matrix_rustpush_bridge_database_sslmode: disable + +matrix_rustpush_bridge_database_connection_string: 'postgres://{{ matrix_rustpush_bridge_database_username }}:{{ matrix_rustpush_bridge_database_password }}@{{ matrix_rustpush_bridge_database_hostname }}:{{ matrix_rustpush_bridge_database_port }}/{{ matrix_rustpush_bridge_database_name }}?sslmode={{ matrix_rustpush_bridge_database_sslmode }}' + +matrix_rustpush_bridge_database_uri: "{{ + { + 'postgres': matrix_rustpush_bridge_database_connection_string, + }[matrix_rustpush_bridge_database_engine] +}}" + +matrix_rustpush_bridge_double_puppet_secrets: "{{ matrix_rustpush_bridge_double_puppet_secrets_auto | combine(matrix_rustpush_bridge_double_puppet_secrets_custom) }}" +matrix_rustpush_bridge_double_puppet_secrets_auto: {} +matrix_rustpush_bridge_double_puppet_secrets_custom: {} + +matrix_rustpush_bridge_appservice_bot_username: imessagebot +matrix_rustpush_bridge_appservice_bot_displayname: iMessage bridge bot +matrix_rustpush_bridge_appservice_bot_avatar: '' + +# Backfill is disabled by default because Linux Docker cannot access chat.db. +# On macOS with Full Disk Access, this can be set to true. +matrix_rustpush_bridge_backfill_enabled: false +# Maximum number of messages to backfill in empty rooms +matrix_rustpush_bridge_backfill_max_initial_messages: 50 + +# Maximum number of missed messages to backfill after bridge restarts +matrix_rustpush_bridge_backfill_max_catchup_messages: 500 + +# How many days back to look for chats during initial sync. +# Default in upstream is 365 (1 year). Set to 0 to disable. +matrix_rustpush_bridge_initial_sync_days: 0 + +# Shared secret for authentication of provisioning API requests. +# If set to "disable", the provisioning API will be disabled. +matrix_rustpush_bridge_provisioning_shared_secret: disable + +# Minimum severity of journal log messages. +# Valid values: fatal, error, warn, info, debug, trace +matrix_rustpush_bridge_logging_level: 'warn' + +# Whether or not metrics endpoint should be enabled. +# Enabling them is usually enough for a local (in-container) Prometheus to consume them. +# If metrics need to be consumed by another (external) Prometheus server, consider exposing them via `matrix_rustpush_bridge_metrics_proxying_enabled`. +matrix_rustpush_bridge_metrics_enabled: false + +# Controls whether metrics should be exposed on a public URL. +matrix_rustpush_bridge_metrics_proxying_enabled: false +matrix_rustpush_bridge_metrics_proxying_hostname: '' +matrix_rustpush_bridge_metrics_proxying_path_prefix: '' + +# Default configuration template which covers the generic use case. +# You can customize it by controlling the various variables inside it. +# +# For a more advanced customization, you can extend the default (see `matrix_rustpush_bridge_configuration_extension_yaml`) +# or completely replace this variable with your own template. +matrix_rustpush_bridge_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}" + +matrix_rustpush_bridge_configuration_extension_yaml: | + # Your custom YAML configuration goes here. + # This configuration extends the default starting configuration (`matrix_rustpush_bridge_configuration_yaml`). + # + # You can override individual variables from the default configuration, or introduce new ones. + # + # If you need something more special, you can take full control by + # completely redefining `matrix_rustpush_bridge_configuration_yaml`. + +matrix_rustpush_bridge_configuration_extension: "{{ matrix_rustpush_bridge_configuration_extension_yaml | from_yaml if matrix_rustpush_bridge_configuration_extension_yaml | from_yaml is mapping else {} }}" + +# Holds the final configuration (a combination of the default and its extension). +# You most likely don't need to touch this variable. Instead, see `matrix_rustpush_bridge_configuration_yaml`. +matrix_rustpush_bridge_configuration: "{{ matrix_rustpush_bridge_configuration_yaml | from_yaml | combine(matrix_rustpush_bridge_configuration_extension, recursive=True) }}" + +matrix_rustpush_bridge_registration_yaml: | + id: rustpush-bridge + as_token: "{{ matrix_rustpush_bridge_appservice_token }}" + hs_token: "{{ matrix_rustpush_bridge_homeserver_token }}" + namespaces: + users: + - exclusive: true + regex: '^@imessage_.+:{{ matrix_rustpush_bridge_homeserver_domain | regex_escape }}$' + - exclusive: true + regex: '^@{{ matrix_rustpush_bridge_appservice_bot_username | regex_escape }}:{{ matrix_rustpush_bridge_homeserver_domain | regex_escape }}$' + url: {{ matrix_rustpush_bridge_appservice_address }} + sender_localpart: _bot_{{ matrix_rustpush_bridge_appservice_bot_username }} + rate_limited: false + de.sorunome.msc2409.push_ephemeral: true + receive_ephemeral: true + io.element.msc4190: {{ matrix_rustpush_bridge_msc4190_enabled | to_json }} + +matrix_rustpush_bridge_registration: "{{ matrix_rustpush_bridge_registration_yaml | from_yaml }}" + +# Enable End-to-bridge encryption +matrix_rustpush_bridge_bridge_encryption_allow: "{{ matrix_bridges_encryption_enabled }}" +matrix_rustpush_bridge_bridge_encryption_default: "{{ matrix_bridges_encryption_default }}" +matrix_rustpush_bridge_bridge_encryption_require: false +matrix_rustpush_bridge_bridge_encryption_appservice: false +matrix_rustpush_bridge_bridge_encryption_key_sharing_allow: "{{ matrix_rustpush_bridge_bridge_encryption_allow }}" +matrix_rustpush_bridge_bridge_encryption_pickle_key: mautrix.bridge.e2ee + +# matrix_rustpush_bridge_restart_necessary controls whether the service +# will be restarted (when true) or merely started (when false) by the +# systemd service manager role (when conditional restart is enabled). +# +# This value is automatically computed during installation based on whether +# any configuration files, the systemd service file, or the container image changed. +# The default of `false` means "no restart needed" — appropriate when the role's +# installation tasks haven't run (e.g., due to --tags skipping them). +matrix_rustpush_bridge_restart_necessary: false diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/main.yml b/roles/custom/matrix-bridge-rustpush/tasks/main.yml similarity index 63% rename from roles/custom/matrix-bridge-imessage-rustpush/tasks/main.yml rename to roles/custom/matrix-bridge-rustpush/tasks/main.yml index a6cd72ef0..5afa35fa5 100644 --- a/roles/custom/matrix-bridge-imessage-rustpush/tasks/main.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/main.yml @@ -6,19 +6,19 @@ - tags: - setup-all - - setup-imessage-rustpush + - setup-rustpush-bridge - install-all - - install-imessage-rustpush + - install-rustpush-bridge block: - - when: matrix_imessage_rustpush_enabled | bool + - when: matrix_rustpush_bridge_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" - - when: matrix_imessage_rustpush_enabled | bool + - when: matrix_rustpush_bridge_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" - tags: - setup-all - - setup-imessage-rustpush + - setup-rustpush-bridge block: - - when: not matrix_imessage_rustpush_enabled | bool + - when: not matrix_rustpush_bridge_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" diff --git a/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml new file mode 100644 index 000000000..ebd9d28e0 --- /dev/null +++ b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml @@ -0,0 +1,115 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- + +- name: Ensure RustPush paths exist + ansible.builtin.file: + path: "{{ item.path }}" + state: directory + mode: 0750 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + with_items: + - {path: "{{ matrix_rustpush_bridge_base_path }}", when: true} + - {path: "{{ matrix_rustpush_bridge_config_path }}", when: true} + - {path: "{{ matrix_rustpush_bridge_data_path }}", when: true} + - {path: "{{ matrix_rustpush_bridge_docker_src_files_path }}", when: "{{ matrix_rustpush_bridge_container_image_self_build }}"} + when: item.when | bool + +- name: Ensure RustPush repository is present on self-build + ansible.builtin.git: + repo: "{{ matrix_rustpush_bridge_container_image_self_build_repo }}" + version: "{{ matrix_rustpush_bridge_container_image_self_build_repo_version }}" + dest: "{{ matrix_rustpush_bridge_docker_src_files_path }}" + force: "yes" + become: true + become_user: "{{ matrix_user_name }}" + register: matrix_rustpush_bridge_git_pull_results + when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build" + +- name: Ensure RustPush Dockerfile is installed + ansible.builtin.template: + src: "{{ role_path }}/templates/Dockerfile.j2" + dest: "{{ matrix_rustpush_bridge_docker_src_files_path }}/Dockerfile" + mode: 0640 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build | bool" + +- name: Ensure RustPush Docker image is built + community.docker.docker_image: + name: "{{ matrix_rustpush_bridge_docker_image }}" + source: build + force_source: "{{ matrix_rustpush_bridge_git_pull_results.changed if matrix_rustpush_bridge_git_pull_results is defined else true }}" + build: + dockerfile: Dockerfile + path: "{{ matrix_rustpush_bridge_docker_src_files_path }}" + pull: true + register: matrix_rustpush_bridge_container_image_build_result + when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build | bool" + +- name: Ensure RustPush container image is pulled + community.docker.docker_image: + name: "{{ matrix_rustpush_bridge_docker_image }}" + source: pull + force_source: "{{ matrix_rustpush_bridge_container_image_force_pull if matrix_rustpush_bridge_container_image_force_pull is defined else true }}" + register: matrix_rustpush_bridge_container_image_pull_result + when: "matrix_rustpush_bridge_enabled | bool and not matrix_rustpush_bridge_container_image_self_build | bool" + ignore_errors: "{{ ansible_check_mode }}" + +- name: Ensure rustpush-bridge config.yaml installed + ansible.builtin.copy: + content: "{{ matrix_rustpush_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}" + dest: "{{ matrix_rustpush_bridge_config_path }}/config.yaml" + mode: 0644 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + register: matrix_rustpush_bridge_config_result + +- name: Ensure rustpush-bridge registration.yaml installed + ansible.builtin.copy: + content: "{{ matrix_rustpush_bridge_registration | to_nice_yaml(indent=2, width=999999) }}" + dest: "{{ matrix_rustpush_bridge_config_path }}/registration.yaml" + mode: 0644 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + register: matrix_rustpush_bridge_registration_result + +- name: Ensure rustpush-bridge support files installed + ansible.builtin.template: + src: "{{ role_path }}/templates/{{ item }}.j2" + dest: "{{ matrix_rustpush_bridge_base_path }}/{{ item }}" + mode: 0640 + owner: "{{ matrix_user_name }}" + group: "{{ matrix_group_name }}" + with_items: + - labels + register: matrix_rustpush_bridge_support_files_result + +- name: Ensure matrix-rustpush-bridge container network is created + community.general.docker_network: + enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}" + name: "{{ matrix_rustpush_bridge_container_network }}" + driver: bridge + driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}" + +- name: Ensure matrix-rustpush-bridge.service installed + ansible.builtin.template: + src: "{{ role_path }}/templates/systemd/matrix-rustpush-bridge.service.j2" + dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rustpush-bridge.service" + mode: 0644 + register: matrix_rustpush_bridge_systemd_service_result + +- name: Determine whether matrix-rustpush-bridge needs a restart + ansible.builtin.set_fact: + matrix_rustpush_bridge_restart_necessary: >- + {{ + matrix_rustpush_bridge_config_result.changed | default(false) + or matrix_rustpush_bridge_registration_result.changed | default(false) + or matrix_rustpush_bridge_support_files_result.changed | default(false) + or matrix_rustpush_bridge_systemd_service_result.changed | default(false) + or matrix_rustpush_bridge_container_image_pull_result.changed | default(false) + or matrix_rustpush_bridge_container_image_build_result.changed | default(false) + }} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_uninstall.yml b/roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml similarity index 50% rename from roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_uninstall.yml rename to roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml index 7ac351bbf..26a5d04e6 100644 --- a/roles/custom/matrix-bridge-imessage-rustpush/tasks/setup_uninstall.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml @@ -4,20 +4,20 @@ --- -- name: Check existence of matrix-imessage-rustpush service +- name: Check existence of matrix-rustpush-bridge service ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-imessage-rustpush.service" - register: matrix_imessage_rustpush_service_stat + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rustpush-bridge.service" + register: matrix_rustpush_bridge_service_stat -- when: matrix_imessage_rustpush_service_stat.stat.exists | bool +- when: matrix_rustpush_bridge_service_stat.stat.exists | bool block: - - name: Ensure matrix-imessage-rustpush is stopped + - name: Ensure matrix-rustpush-bridge is stopped ansible.builtin.service: - name: matrix-imessage-rustpush + name: matrix-rustpush-bridge state: stopped daemon_reload: true - - name: Ensure matrix-imessage-rustpush.service doesn't exist + - name: Ensure matrix-rustpush-bridge.service doesn't exist ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-imessage-rustpush.service" + path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rustpush-bridge.service" state: absent diff --git a/roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml b/roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml new file mode 100644 index 000000000..99011123f --- /dev/null +++ b/roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2025 MDAD project contributors +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- + +- name: Fail if required RustPush settings not defined + ansible.builtin.fail: + msg: >- + You need to define a required configuration setting (`{{ item.name }}`). + when: "item.when | bool and lookup('vars', item.name, default='') | string | length == 0" + with_items: + - {'name': 'matrix_rustpush_bridge_appservice_token', when: true} + - {'name': 'matrix_rustpush_bridge_homeserver_address', when: true} + - {'name': 'matrix_rustpush_bridge_homeserver_token', when: true} + - {'name': 'matrix_rustpush_bridge_database_hostname', when: "{{ matrix_rustpush_bridge_database_engine == 'postgres' }}"} + - {'name': 'matrix_rustpush_bridge_container_network', when: true} + - {'name': 'matrix_rustpush_bridge_metrics_proxying_hostname', when: "{{ matrix_rustpush_bridge_metrics_proxying_enabled }}"} + - {'name': 'matrix_rustpush_bridge_metrics_proxying_path_prefix', when: "{{ matrix_rustpush_bridge_metrics_proxying_enabled }}"} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2 b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 similarity index 100% rename from roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2 rename to roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2.license b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2.license similarity index 100% rename from roles/custom/matrix-bridge-imessage-rustpush/templates/Dockerfile.j2.license rename to roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2.license diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2 b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 similarity index 69% rename from roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2 rename to roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 index ed99483f6..cddebe99b 100644 --- a/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 @@ -4,16 +4,16 @@ network: # Displayname template for iMessage contacts. # Available variables: {{.FirstName}}, {{.LastName}}, {{.Nickname}}, # {{.Phone}}, {{.Email}}, {{.ID}} - displayname_template: {{ matrix_imessage_rustpush_network_displayname_template | to_json }} + displayname_template: {{ matrix_rustpush_bridge_network_displayname_template | to_json }} # How many days back to look for chats during initial sync. # Default is 365 (1 year). Set to 0 to use the default. - initial_sync_days: {{ matrix_imessage_rustpush_initial_sync_days | to_json }} + initial_sync_days: {{ matrix_rustpush_bridge_initial_sync_days | to_json }} # Config options that affect the central bridge module. bridge: # The prefix for commands. Only required in non-management rooms. - command_prefix: {{ matrix_imessage_rustpush_bridge_command_prefix | to_json }} + command_prefix: {{ matrix_rustpush_bridge_bridge_command_prefix | to_json }} # Should the bridge create a space for each login containing the rooms that account is in? personal_filtering_spaces: true # Whether the bridge should set names and avatars explicitly for DM portals. @@ -65,12 +65,12 @@ bridge: displayname_format: "{% raw %}{{ .DisambiguatedName }}{% endraw %}" # Permissions for using the bridge. - permissions: {{ matrix_imessage_rustpush_bridge_permissions | to_json }} + permissions: {{ matrix_rustpush_bridge_bridge_permissions | to_json }} # Config for the bridge's database. database: type: postgres - uri: {{ matrix_imessage_rustpush_database_uri | to_json }} + uri: {{ matrix_rustpush_bridge_database_uri | to_json }} max_open_conns: 5 max_idle_conns: 1 max_conn_idle_time: null @@ -78,34 +78,34 @@ database: # Homeserver details. homeserver: - address: {{ matrix_imessage_rustpush_homeserver_address | to_json }} - domain: {{ matrix_imessage_rustpush_homeserver_domain | to_json }} + address: {{ matrix_rustpush_bridge_homeserver_address | to_json }} + domain: {{ matrix_rustpush_bridge_homeserver_domain | to_json }} software: standard status_endpoint: message_send_checkpoint_endpoint: - async_media: {{ matrix_imessage_rustpush_homeserver_async_media | to_json }} + async_media: {{ matrix_rustpush_bridge_homeserver_async_media | to_json }} websocket: false ping_interval_seconds: 0 # Application service host/registration related details. appservice: - address: {{ matrix_imessage_rustpush_appservice_address | to_json }} - public_address: {{ matrix_imessage_rustpush_appservice_public_address | to_json }} + address: {{ matrix_rustpush_bridge_appservice_address | to_json }} + public_address: {{ matrix_rustpush_bridge_appservice_public_address | to_json }} hostname: 0.0.0.0 port: 8081 - id: imessage-rustpush + id: rustpush-bridge bot: - username: {{ matrix_imessage_rustpush_appservice_bot_username | to_json }} - displayname: {{ matrix_imessage_rustpush_appservice_bot_displayname | to_json(ensure_ascii=False) }} - avatar: {{ matrix_imessage_rustpush_appservice_bot_avatar | to_json }} + username: {{ matrix_rustpush_bridge_appservice_bot_username | to_json }} + displayname: {{ matrix_rustpush_bridge_appservice_bot_displayname | to_json(ensure_ascii=False) }} + avatar: {{ matrix_rustpush_bridge_appservice_bot_avatar | to_json }} ephemeral_events: true async_transactions: false - as_token: {{ matrix_imessage_rustpush_appservice_token | to_json }} - hs_token: {{ matrix_imessage_rustpush_homeserver_token | to_json }} + as_token: {{ matrix_rustpush_bridge_appservice_token | to_json }} + hs_token: {{ matrix_rustpush_bridge_homeserver_token | to_json }} # Localpart template of MXIDs for remote users. username_template: "{% raw %}imessage_{{.}}{% endraw %}" @@ -116,7 +116,7 @@ matrix: delivery_receipts: false message_error_notices: true sync_direct_chat_list: true - federate_rooms: {{ matrix_imessage_rustpush_matrix_federate_rooms | to_json }} + federate_rooms: {{ matrix_rustpush_bridge_matrix_federate_rooms | to_json }} upload_file_threshold: 5242880 # Segment-compatible analytics endpoint for tracking some events. @@ -128,15 +128,15 @@ analytics: # Settings for provisioning API provisioning: prefix: /_matrix/provision - shared_secret: {{ matrix_imessage_rustpush_provisioning_shared_secret | to_json }} + shared_secret: {{ matrix_rustpush_bridge_provisioning_shared_secret | to_json }} allow_matrix_auth: true debug_endpoints: false # Settings for backfilling messages. backfill: - enabled: {{ matrix_imessage_rustpush_backfill_enabled | to_json }} - max_initial_messages: {{ matrix_imessage_rustpush_backfill_max_initial_messages | to_json }} - max_catchup_messages: {{ matrix_imessage_rustpush_backfill_max_catchup_messages | to_json }} + enabled: {{ matrix_rustpush_bridge_backfill_enabled | to_json }} + max_initial_messages: {{ matrix_rustpush_bridge_backfill_max_initial_messages | to_json }} + max_catchup_messages: {{ matrix_rustpush_bridge_backfill_max_catchup_messages | to_json }} unread_hours_threshold: 720 threads: max_initial_messages: 50 @@ -151,18 +151,18 @@ backfill: double_puppet: servers: {} allow_discovery: false - secrets: {{ matrix_imessage_rustpush_double_puppet_secrets | to_json }} + secrets: {{ matrix_rustpush_bridge_double_puppet_secrets | to_json }} # End-to-bridge encryption support options. encryption: - allow: {{ matrix_imessage_rustpush_bridge_encryption_allow | to_json }} - default: {{ matrix_imessage_rustpush_bridge_encryption_default | to_json }} - require: {{ matrix_imessage_rustpush_bridge_encryption_require | to_json }} - appservice: {{ matrix_imessage_rustpush_bridge_encryption_appservice | to_json }} - msc4190: {{ matrix_imessage_rustpush_msc4190_enabled | to_json }} - self_sign: {{ matrix_imessage_rustpush_self_sign_enabled | to_json }} - allow_key_sharing: {{ matrix_imessage_rustpush_bridge_encryption_key_sharing_allow | to_json }} - pickle_key: {{ matrix_imessage_rustpush_bridge_encryption_pickle_key | to_json }} + allow: {{ matrix_rustpush_bridge_bridge_encryption_allow | to_json }} + default: {{ matrix_rustpush_bridge_bridge_encryption_default | to_json }} + require: {{ matrix_rustpush_bridge_bridge_encryption_require | to_json }} + appservice: {{ matrix_rustpush_bridge_bridge_encryption_appservice | to_json }} + msc4190: {{ matrix_rustpush_bridge_msc4190_enabled | to_json }} + self_sign: {{ matrix_rustpush_bridge_self_sign_enabled | to_json }} + allow_key_sharing: {{ matrix_rustpush_bridge_bridge_encryption_key_sharing_allow | to_json }} + pickle_key: {{ matrix_rustpush_bridge_bridge_encryption_pickle_key | to_json }} delete_keys: delete_outbound_on_ack: false dont_store_outbound: false @@ -184,7 +184,7 @@ encryption: # Logging config. logging: - min_level: {{ matrix_imessage_rustpush_logging_level | to_json }} + min_level: {{ matrix_rustpush_bridge_logging_level | to_json }} writers: - type: stdout format: pretty-colored diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2.license b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2.license similarity index 100% rename from roles/custom/matrix-bridge-imessage-rustpush/templates/config.yaml.j2.license rename to roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2.license diff --git a/roles/custom/matrix-bridge-rustpush/templates/labels.j2 b/roles/custom/matrix-bridge-rustpush/templates/labels.j2 new file mode 100644 index 000000000..0b42e56be --- /dev/null +++ b/roles/custom/matrix-bridge-rustpush/templates/labels.j2 @@ -0,0 +1,52 @@ +{# +SPDX-FileCopyrightText: 2025 MDAD project contributors + +SPDX-License-Identifier: AGPL-3.0-or-later +#} + +{% if matrix_rustpush_bridge_container_labels_traefik_enabled %} +traefik.enable=true + +{% if matrix_rustpush_bridge_container_labels_traefik_docker_network %} +traefik.docker.network={{ matrix_rustpush_bridge_container_labels_traefik_docker_network }} +{% endif %} + +traefik.http.services.matrix-rustpush-bridge-metrics.loadbalancer.server.port=8000 + +{% if matrix_rustpush_bridge_container_labels_metrics_enabled %} +############################################################ +# # +# Metrics # +# # +############################################################ + +{% if matrix_rustpush_bridge_container_labels_metrics_middleware_basic_auth_enabled %} +traefik.http.middlewares.matrix-rustpush-bridge-metrics-basic-auth.basicauth.users={{ matrix_rustpush_bridge_container_labels_metrics_middleware_basic_auth_users }} +traefik.http.routers.matrix-rustpush-bridge-metrics.middlewares=matrix-rustpush-bridge-metrics-basic-auth +{% endif %} + +traefik.http.routers.matrix-rustpush-bridge-metrics.rule={{ matrix_rustpush_bridge_container_labels_metrics_traefik_rule }} + +{% if matrix_rustpush_bridge_container_labels_metrics_traefik_priority | int > 0 %} +traefik.http.routers.matrix-rustpush-bridge-metrics.priority={{ matrix_rustpush_bridge_container_labels_metrics_traefik_priority }} +{% endif %} + +traefik.http.routers.matrix-rustpush-bridge-metrics.service=matrix-rustpush-bridge-metrics +traefik.http.routers.matrix-rustpush-bridge-metrics.entrypoints={{ matrix_rustpush_bridge_container_labels_metrics_traefik_entrypoints }} + +traefik.http.routers.matrix-rustpush-bridge-metrics.tls={{ matrix_rustpush_bridge_container_labels_metrics_traefik_tls | to_json }} +{% if matrix_rustpush_bridge_container_labels_metrics_traefik_tls %} +traefik.http.routers.matrix-rustpush-bridge-metrics.tls.certResolver={{ matrix_rustpush_bridge_container_labels_metrics_traefik_tls_certResolver }} +{% endif %} + +############################################################ +# # +# /Metrics # +# # +############################################################ +{% endif %} + + +{% endif %} + +{{ matrix_rustpush_bridge_container_labels_additional_labels }} diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2.license b/roles/custom/matrix-bridge-rustpush/templates/labels.j2.license similarity index 100% rename from roles/custom/matrix-bridge-imessage-rustpush/templates/labels.j2.license rename to roles/custom/matrix-bridge-rustpush/templates/labels.j2.license diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 similarity index 57% rename from roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 rename to roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 index 3c40267a2..3a38291ec 100644 --- a/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 @@ -1,11 +1,11 @@ #jinja2: lstrip_blocks: True [Unit] -Description=Matrix iMessage RustPush bridge -{% for service in matrix_imessage_rustpush_systemd_required_services_list %} +Description=Matrix RustPush bridge +{% for service in matrix_rustpush_bridge_systemd_required_services_list %} Requires={{ service }} After={{ service }} {% endfor %} -{% for service in matrix_imessage_rustpush_systemd_wanted_services_list %} +{% for service in matrix_rustpush_bridge_systemd_wanted_services_list %} Wants={{ service }} {% endfor %} DefaultDependencies=no @@ -13,36 +13,36 @@ DefaultDependencies=no [Service] Type=simple Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}" -ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-imessage-rustpush 2>/dev/null || true' -ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-imessage-rustpush 2>/dev/null || true' +ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-rustpush-bridge 2>/dev/null || true' +ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-rustpush-bridge 2>/dev/null || true' ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --rm \ - --name=matrix-imessage-rustpush \ + --name=matrix-rustpush-bridge \ --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ - --network={{ matrix_imessage_rustpush_container_network }} \ - --mount type=bind,src={{ matrix_imessage_rustpush_config_path }},dst=/config,ro \ - --mount type=bind,src={{ matrix_imessage_rustpush_data_path }},dst=/data \ - --label-file={{ matrix_imessage_rustpush_base_path }}/labels \ - {% for arg in matrix_imessage_rustpush_container_extra_arguments %} + --network={{ matrix_rustpush_bridge_container_network }} \ + --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config,ro \ + --mount type=bind,src={{ matrix_rustpush_bridge_data_path }},dst=/data \ + --label-file={{ matrix_rustpush_bridge_base_path }}/labels \ + {% for arg in matrix_rustpush_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} - {{ matrix_imessage_rustpush_docker_image }} \ + {{ matrix_rustpush_bridge_docker_image }} \ /usr/bin/mautrix-imessage-v2 -c /config/config.yaml -r /config/registration.yaml --no-update -{% for network in matrix_imessage_rustpush_container_additional_networks %} -ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-imessage-rustpush +{% for network in matrix_rustpush_bridge_container_additional_networks %} +ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-rustpush-bridge {% endfor %} -ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-imessage-rustpush +ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-rustpush-bridge -ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-imessage-rustpush 2>/dev/null || true' -ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-imessage-rustpush 2>/dev/null || true' +ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-rustpush-bridge 2>/dev/null || true' +ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-rustpush-bridge 2>/dev/null || true' Restart=always RestartSec=30 -SyslogIdentifier=matrix-imessage-rustpush +SyslogIdentifier=matrix-rustpush-bridge [Install] WantedBy=multi-user.target diff --git a/roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2.license b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2.license similarity index 100% rename from roles/custom/matrix-bridge-imessage-rustpush/templates/systemd/matrix-imessage-rustpush.service.j2.license rename to roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2.license diff --git a/setup.yml b/setup.yml index 4369a83fe..241cad51a 100644 --- a/setup.yml +++ b/setup.yml @@ -71,7 +71,7 @@ - custom/matrix-bridge-mautrix-discord - custom/matrix-bridge-mautrix-slack - custom/matrix-bridge-mautrix-bluesky - - custom/matrix-bridge-imessage-rustpush + - custom/matrix-bridge-rustpush - custom/matrix-bridge-mx-puppet-groupme - custom/matrix-bridge-mx-puppet-steam - custom/matrix-bridge-postmoogle From 0b5e5cd6dc84deb7df327c7f3287b9772a20f900 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Wed, 27 May 2026 17:56:36 -0700 Subject: [PATCH 03/23] Expose config.yaml via mount --- .../matrix-bridge-rustpush/defaults/main.yml | 8 +- .../templates/Dockerfile.j2 | 109 ++++++++++++++---- .../systemd/matrix-rustpush-bridge.service.j2 | 3 +- 3 files changed, 92 insertions(+), 28 deletions(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index ebc292793..8d6a31952 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -4,17 +4,17 @@ --- # matrix-bridge-rustpush is a Matrix <-> iMessage bridge using RustPush -# Project source code URL: https://github.com/lrhodin/imessage +# Project source code URL: https://github.com/jasonlaguidice/imessage matrix_rustpush_bridge_enabled: true # No upstream Docker image exists; self-build is always required. matrix_rustpush_bridge_container_image_self_build: true -matrix_rustpush_bridge_container_image_self_build_repo: "https://github.com/lrhodin/imessage.git" -matrix_rustpush_bridge_container_image_self_build_repo_version: "{{ 'main' if matrix_rustpush_bridge_version == 'latest' else matrix_rustpush_bridge_version }}" +matrix_rustpush_bridge_container_image_self_build_repo: "https://github.com/jasonlaguidice/imessage.git" +matrix_rustpush_bridge_container_image_self_build_repo_version: "{{ 'master' if matrix_rustpush_bridge_version == 'latest' else matrix_rustpush_bridge_version }}" matrix_rustpush_bridge_version: latest -matrix_rustpush_bridge_docker_image: "{{ matrix_rustpush_bridge_docker_image_registry_prefix }}lrhodin/imessage:{{ matrix_rustpush_bridge_version }}" +matrix_rustpush_bridge_docker_image: "{{ matrix_rustpush_bridge_docker_image_registry_prefix }}jasonlaguidice/imessage:{{ matrix_rustpush_bridge_version }}" matrix_rustpush_bridge_docker_image_registry_prefix: "localhost/" matrix_rustpush_bridge_docker_image_force_pull: "{{ matrix_rustpush_bridge_docker_image.endswith(':latest') }}" diff --git a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 index 58baef06b..a46a432fc 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 @@ -4,42 +4,105 @@ SPDX-FileCopyrightText: 2025 MDAD project contributors SPDX-License-Identifier: AGPL-3.0-or-later #} -# Multi-stage build for mautrix-imessage with RustPush support -# Stage 1: Rust + Go builder -FROM docker.io/golang:1.24-bookworm AS builder +# ── Stage 1: builder ───────────────────────────────────────────────────────── +FROM ubuntu:24.04 AS builder -# Install Rust toolchain -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" +ENV DEBIAN_FRONTEND=noninteractive -# Install build dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - clang \ - libclang-dev \ - protobuf-compiler \ - git \ - ca-certificates \ + cmake protobuf-compiler build-essential pkg-config \ + git curl ca-certificates \ + libolm-dev libclang-dev libssl-dev libunicorn-dev libheif-dev zlib1g-dev \ && rm -rf /var/lib/apt/lists/* +# Rust — install to default ~/.cargo so the Makefile's $(HOME)/.cargo/bin path resolves +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | sh -s -- -y --default-toolchain stable +ENV PATH=/root/.cargo/bin:$PATH + +# Go — arch-aware, fetches latest stable with fallback +ARG TARGETARCH +RUN set -e; \ + GOARCH="${TARGETARCH:-amd64}"; \ + GO_VERSION=$(curl -fsSL 'https://go.dev/dl/?mode=json' \ + | grep -o '"version":"go[0-9.]*"' | head -1 \ + | sed 's/"version":"//;s/"//'); \ + : "${GO_VERSION:=go1.25.0}"; \ + curl -fsSL "https://go.dev/dl/${GO_VERSION}.linux-${GOARCH}.tar.gz" \ + | tar -C /usr/local -xz +ENV PATH=/usr/local/go/bin:$PATH \ + GOTOOLCHAIN=local + WORKDIR /build -# Copy the source code -COPY . /build/ +# ── Rust build layers ───────────────────────────────────────────────────────── +# Copy files that determine whether the clone+patch layer is valid. +# Changing the SHA pin, Makefile, or open-absinthe overlay invalidates this layer. +COPY third_party/rustpush-upstream.sha third_party/ +COPY rustpush/ rustpush/ +COPY Makefile . + +# Clone upstream rustpush at the pinned SHA, apply all patches, overlay open-absinthe. +RUN make ensure-rustpush-source + +# Copy Rust crate sources. Changing these invalidates only the Rust build layer, +# not the clone layer above. +COPY pkg/rustpushgo/ pkg/rustpushgo/ +COPY nac-validation/ nac-validation/ + +# Build the Rust static library (~3 min; cached when Rust source is unchanged). +# hardware-key enables the unicorn-based x86 NAC emulator required on Linux +# (both amd64 and arm64 — unicorn supports cross-arch x86 emulation). +RUN cd pkg/rustpushgo && \ + cargo build --release --features hardware-key && \ + cp target/release/librustpushgo.a /build/librustpushgo.a + +# ── Go build layers ─────────────────────────────────────────────────────────── +# Download modules first so this layer is cached by go.mod/go.sum. +COPY go.mod go.sum ./ +RUN go mod download + +# Copy Go source. +COPY cmd/ cmd/ +COPY pkg/connector/ pkg/connector/ +COPY imessage/ imessage/ +COPY ipc/ ipc/ + +# Build the bridge binary. +ARG BUILD_VERSION=dev +ARG BUILD_COMMIT=unknown +RUN BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) && \ + CGO_LDFLAGS="-L/build" \ + go build \ + -ldflags "-X main.Tag=${BUILD_VERSION} -X main.Commit=${BUILD_COMMIT} -X main.BuildTime=${BUILD_TIME}" \ + -o /build/mautrix-imessage-v2 \ + ./cmd/mautrix-imessage/ -# Build the Go binary with CGO enabled (required for Rust FFI) -RUN cd /build && make build +# ── Stage 2: runtime ───────────────────────────────────────────────────────── +FROM ubuntu:24.04 -# Stage 2: Runtime -FROM docker.io/debian:bookworm-slim +ENV DEBIAN_FRONTEND=noninteractive +# Runtime shared libraries the bridge binary needs at startup. +# libunicorn2 — unicorn-engine x86 NAC emulator (hardware-key feature) +# libheif1 — HEIC/HEIF conversion (linked at compile time even when disabled) +# libolm3 — Matrix OLM encryption (mautrix bridgev2 framework) +# libssl3 — OpenSSL (rustpush openssl crate dynamic link) RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ + libunicorn2 libheif1 libolm3 libssl3 \ + ca-certificates openssl curl \ + && curl -fsSL 'https://www.apple.com/appleca/AppleIncRootCertificate.cer' \ + -o /tmp/AppleRootCA.cer \ + && openssl x509 -inform DER -in /tmp/AppleRootCA.cer \ + -out /usr/local/share/ca-certificates/AppleRootCA.crt \ + && update-ca-certificates \ + && rm /tmp/AppleRootCA.cer \ && rm -rf /var/lib/apt/lists/* -COPY --from=builder /build/mautrix-imessage-v2 /usr/bin/mautrix-imessage-v2 +COPY --from=builder /build/mautrix-imessage-v2 /usr/local/bin/mautrix-imessage-v2 +WORKDIR /data VOLUME /data -VOLUME /config +EXPOSE 29332 -CMD ["/usr/bin/mautrix-imessage-v2", "-c", "/config/config.yaml", "-r", "/config/registration.yaml", "--no-update"] +ENTRYPOINT ["mautrix-imessage-v2", "-c", "/data/config.yaml"] diff --git a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 index 3a38291ec..f72f05066 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 @@ -26,11 +26,12 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config,ro \ --mount type=bind,src={{ matrix_rustpush_bridge_data_path }},dst=/data \ --label-file={{ matrix_rustpush_bridge_base_path }}/labels \ + --entrypoint /usr/local/bin/mautrix-imessage-v2 \ {% for arg in matrix_rustpush_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} {{ matrix_rustpush_bridge_docker_image }} \ - /usr/bin/mautrix-imessage-v2 -c /config/config.yaml -r /config/registration.yaml --no-update + -c /config/config.yaml -r /config/registration.yaml {% for network in matrix_rustpush_bridge_container_additional_networks %} ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-rustpush-bridge From 4b1677fa5035d0b2903f150ecaf1fb16d50065d7 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Wed, 27 May 2026 18:37:19 -0700 Subject: [PATCH 04/23] Fix docs --- docs/configuring-playbook-bridge-rustpush.md | 18 +++++------------- ...iguring-playbook-bridge-rustpush.md.license | 3 --- 2 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 docs/configuring-playbook-bridge-rustpush.md.license diff --git a/docs/configuring-playbook-bridge-rustpush.md b/docs/configuring-playbook-bridge-rustpush.md index b92c98df0..66e435d19 100644 --- a/docs/configuring-playbook-bridge-rustpush.md +++ b/docs/configuring-playbook-bridge-rustpush.md @@ -8,11 +8,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later Refer the common guide for configuring mautrix bridges: [Setting up a Generic Mautrix Bridge](configuring-playbook-bridge-mautrix-bridges.md) -The playbook can install and configure [mautrix-imessage with RustPush](https://github.com/lrhodin/imessage) for you, which provides a bridge to [iMessage](https://support.apple.com/messages) using Apple's push notification service (no Mac needed at runtime). +The playbook can install and configure [rustpush to bridge iMessage](https://github.com/jasonlaguidice/imessage) for you using Apple's push notification service (no Mac needed at runtime). -See the project's [documentation](https://github.com/lrhodin/imessage/blob/main/README.md) to learn what it does and why it might be useful to you. - -**Note**: This bridge is built from source (no pre-built Docker image exists). The build process requires Rust, Go, and C toolchains, which means the initial build will take significant time and resources. +See the project's [documentation](https://github.com/jasonlaguidice/imessage/blob/main/README.md) to learn what it does and why it might be useful to you. ## Prerequisites @@ -20,7 +18,7 @@ See the project's [documentation](https://github.com/lrhodin/imessage/blob/main/ To use this bridge on Linux (Docker), you need a **hardware key** extracted from a real Mac. This key contains hardware identifiers needed for iMessage registration. -The key is entered interactively through the bridge bot's login flow (not configured via Ansible variables). See the upstream [README](https://github.com/lrhodin/imessage/blob/main/README.md) for instructions on extracting the key. +The key is entered interactively through the bridge bot's login flow (not configured via Ansible variables). See the upstream [README](https://github.com/jasonlaguidice/imessage/blob/main/README.md) for instructions on extracting the key. ### Enable Appservice Double Puppet (optional) @@ -38,11 +36,10 @@ matrix_rustpush_bridge_enabled: true ### Backfill (optional) -Backfill is disabled by default because Linux Docker cannot access the macOS `chat.db` file. If you are running on macOS with Full Disk Access, you can enable it: +Backfill can be disabled globally if desired via config. Backfill from chat.db is disabled Linux Docker cannot access the macOS `chat.db` file. ```yaml -matrix_rustpush_bridge_backfill_enabled: true -matrix_rustpush_bridge_initial_sync_days: 365 +matrix_rustpush_bridge_backfill_enabled: false ``` ### Extending the configuration @@ -72,11 +69,6 @@ ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start To use the bridge, you need to start a chat with `@imessagebot:example.com` (where `example.com` is your base domain, not the `matrix.` domain). -The bridge supports two login flows: - -1. **External Key Login** (Linux/Docker): Enter your hardware key (base64), then Apple ID credentials and 2FA code. -2. **Apple ID Login** (macOS only): Enter Apple ID credentials and 2FA code directly. - After logging in, the bridge will start receiving iMessages and creating portal rooms. ## Troubleshooting diff --git a/docs/configuring-playbook-bridge-rustpush.md.license b/docs/configuring-playbook-bridge-rustpush.md.license deleted file mode 100644 index 826be4a75..000000000 --- a/docs/configuring-playbook-bridge-rustpush.md.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 MDAD project contributors - -SPDX-License-Identifier: AGPL-3.0-or-later From 210b7b3b0dfb930e98fbf1a947d01924ae461985 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Wed, 27 May 2026 23:12:47 -0700 Subject: [PATCH 05/23] Default config mapping --- .../matrix-bridge-rustpush/defaults/main.yml | 17 ++++++++++++----- .../templates/config.yaml.j2 | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index 8d6a31952..ea8f01d0b 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -6,16 +6,16 @@ # matrix-bridge-rustpush is a Matrix <-> iMessage bridge using RustPush # Project source code URL: https://github.com/jasonlaguidice/imessage -matrix_rustpush_bridge_enabled: true +matrix_rustpush_bridge_enabled: false -# No upstream Docker image exists; self-build is always required. -matrix_rustpush_bridge_container_image_self_build: true +matrix_rustpush_bridge_container_image_self_build: false matrix_rustpush_bridge_container_image_self_build_repo: "https://github.com/jasonlaguidice/imessage.git" matrix_rustpush_bridge_container_image_self_build_repo_version: "{{ 'master' if matrix_rustpush_bridge_version == 'latest' else matrix_rustpush_bridge_version }}" +# Adjust to pin to releases matrix_rustpush_bridge_version: latest matrix_rustpush_bridge_docker_image: "{{ matrix_rustpush_bridge_docker_image_registry_prefix }}jasonlaguidice/imessage:{{ matrix_rustpush_bridge_version }}" -matrix_rustpush_bridge_docker_image_registry_prefix: "localhost/" +matrix_rustpush_bridge_docker_image_registry_prefix: "ghcr.io/" matrix_rustpush_bridge_docker_image_force_pull: "{{ matrix_rustpush_bridge_docker_image.endswith(':latest') }}" matrix_rustpush_bridge_base_path: "{{ matrix_base_data_path }}/rustpush-bridge" @@ -40,7 +40,14 @@ matrix_rustpush_bridge_appservice_public_address: '' # {{.Phone}}, {{.Email}}, {{.ID}} matrix_rustpush_bridge_network_displayname_template: "{% raw %}{{if .FirstName}}{{.FirstName}}{{if .LastName}} {{.LastName}}{{end}}{{else if .Nickname}}{{.Nickname}}{{else if .Phone}}{{.Phone}}{{else if .Email}}{{.Email}}{{else}}{{.ID}}{{end}}{% endraw %}" -matrix_rustpush_bridge_bridge_command_prefix: "!imessage" +matrix_rustpush_bridge_cloudkit_backfill: true +matrix_rustpush_bridge_video_transcoding: true +matrix_rustpush_bridge_heic_conversion: true +matrix_rustpush_bridge_disable_facetime: false +matrix_rustpush_bridge_statuskit_notifications: true +matrix_rustpush_bridge_statuskit_share_on_startup: true + +matrix_rustpush_bridge_bridge_command_prefix: "!im" matrix_rustpush_bridge_bridge_permissions: | {{ diff --git a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 index cddebe99b..08faf2fa8 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 @@ -10,6 +10,24 @@ network: # Default is 365 (1 year). Set to 0 to use the default. initial_sync_days: {{ matrix_rustpush_bridge_initial_sync_days | to_json }} + # Set to false to disable CloudKit backfill globally + cloudkit_backfill: {{ matrix_rustpush_bridge_cloudkit_backfill | to_json }} + backfill_source: cloudkit + + # Enable or disable video transcoding + video_transcoding: {{ matrix_rustpush_bridge_video_transcoding | to_json }} + + # Enable or disable HEIC conversion + heic_conversion: {{ matrix_rustpush_bridge_heic_conversion | to_json }} + heic_jpeg_quality: 95 + + # Set to true to disable Facetime support globally + disable_facetime: {{ matrix_rustpush_bridge_disable_facetime | to_json }} + + # Set to false to disable Statuskit support globally + statuskit_notifications: {{ matrix_rustpush_bridge_statuskit_notifications | to_json }} + statuskit_share_on_startup: {{ matrix_rustpush_bridge_statuskit_share_on_startup | to_json }} + # Config options that affect the central bridge module. bridge: # The prefix for commands. Only required in non-management rooms. From b1cb0fa2c886b5388f81e5610ef863c776b0b878 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Wed, 27 May 2026 23:31:56 -0700 Subject: [PATCH 06/23] Add ffmpeg, remove mautrix branding --- .../matrix-bridge-rustpush/templates/Dockerfile.j2 | 11 ++++++----- .../systemd/matrix-rustpush-bridge.service.j2 | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 index a46a432fc..49185aef4 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 @@ -75,8 +75,8 @@ RUN BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) && \ CGO_LDFLAGS="-L/build" \ go build \ -ldflags "-X main.Tag=${BUILD_VERSION} -X main.Commit=${BUILD_COMMIT} -X main.BuildTime=${BUILD_TIME}" \ - -o /build/mautrix-imessage-v2 \ - ./cmd/mautrix-imessage/ + -o /build/matrix-rustpush \ + ./cmd/matrix-rustpush/ # ── Stage 2: runtime ───────────────────────────────────────────────────────── FROM ubuntu:24.04 @@ -88,8 +88,9 @@ ENV DEBIAN_FRONTEND=noninteractive # libheif1 — HEIC/HEIF conversion (linked at compile time even when disabled) # libolm3 — Matrix OLM encryption (mautrix bridgev2 framework) # libssl3 — OpenSSL (rustpush openssl crate dynamic link) +# ffmpeg — video transcoding RUN apt-get update && apt-get install -y --no-install-recommends \ - libunicorn2 libheif1 libolm3 libssl3 \ + libunicorn2 libheif1 libolm3 libssl3 ffmpeg \ ca-certificates openssl curl \ && curl -fsSL 'https://www.apple.com/appleca/AppleIncRootCertificate.cer' \ -o /tmp/AppleRootCA.cer \ @@ -99,10 +100,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm /tmp/AppleRootCA.cer \ && rm -rf /var/lib/apt/lists/* -COPY --from=builder /build/mautrix-imessage-v2 /usr/local/bin/mautrix-imessage-v2 +COPY --from=builder /build/matrix-rustpush /usr/local/bin/matrix-rustpush WORKDIR /data VOLUME /data EXPOSE 29332 -ENTRYPOINT ["mautrix-imessage-v2", "-c", "/data/config.yaml"] +ENTRYPOINT ["matrix-rustpush", "-c", "/data/config.yaml"] diff --git a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 index f72f05066..339599fa4 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 @@ -26,7 +26,7 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config,ro \ --mount type=bind,src={{ matrix_rustpush_bridge_data_path }},dst=/data \ --label-file={{ matrix_rustpush_bridge_base_path }}/labels \ - --entrypoint /usr/local/bin/mautrix-imessage-v2 \ + --entrypoint /usr/local/bin/matrix-rustpush \ {% for arg in matrix_rustpush_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} From b44d65fa62e9be699af5a8531f6ef29363d4a037 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sat, 30 May 2026 17:04:05 -0700 Subject: [PATCH 07/23] Fix raw parse --- roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 index 08faf2fa8..912cac44c 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 @@ -2,8 +2,8 @@ # Network-specific config options (iMessage via RustPush) network: # Displayname template for iMessage contacts. - # Available variables: {{.FirstName}}, {{.LastName}}, {{.Nickname}}, - # {{.Phone}}, {{.Email}}, {{.ID}} + # Available variables: {% raw %}{{.FirstName}}, {{.LastName}}, {{.Nickname}}, + # {{.Phone}}, {{.Email}}, {{.ID}}{% endraw %} displayname_template: {{ matrix_rustpush_bridge_network_displayname_template | to_json }} # How many days back to look for chats during initial sync. From e00ab3fc55fc16e355bf8529923c7e17c21867c3 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sat, 30 May 2026 17:56:13 -0700 Subject: [PATCH 08/23] Move base bridge path --- roles/custom/matrix-bridge-rustpush/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index ea8f01d0b..aaddae144 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -18,7 +18,7 @@ matrix_rustpush_bridge_docker_image: "{{ matrix_rustpush_bridge_docker_image_reg matrix_rustpush_bridge_docker_image_registry_prefix: "ghcr.io/" matrix_rustpush_bridge_docker_image_force_pull: "{{ matrix_rustpush_bridge_docker_image.endswith(':latest') }}" -matrix_rustpush_bridge_base_path: "{{ matrix_base_data_path }}/rustpush-bridge" +matrix_rustpush_bridge_base_path: "{{ matrix_base_data_path }}/matrix-rustpush-bridge" matrix_rustpush_bridge_config_path: "{{ matrix_rustpush_bridge_base_path }}/config" matrix_rustpush_bridge_data_path: "{{ matrix_rustpush_bridge_base_path }}/data" matrix_rustpush_bridge_docker_src_files_path: "{{ matrix_rustpush_bridge_base_path }}/docker-src" From 7d345bf3e95791b0e20e462de9c8903237e325d7 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sat, 30 May 2026 17:56:32 -0700 Subject: [PATCH 09/23] Disable room federation by default --- roles/custom/matrix-bridge-rustpush/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index aaddae144..5c324b9dd 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -107,7 +107,7 @@ matrix_rustpush_bridge_homeserver_token: '' # Whether or not created rooms should have federation enabled. # If false, created portal rooms will never be federated. -matrix_rustpush_bridge_matrix_federate_rooms: true +matrix_rustpush_bridge_matrix_federate_rooms: false # Database-related configuration fields. # From 2fe177829c84b93390c2795b6b2adb3569b618f5 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sat, 30 May 2026 17:56:43 -0700 Subject: [PATCH 10/23] Enable an initial sync duration --- roles/custom/matrix-bridge-rustpush/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index 5c324b9dd..57c674b47 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -149,7 +149,7 @@ matrix_rustpush_bridge_backfill_max_catchup_messages: 500 # How many days back to look for chats during initial sync. # Default in upstream is 365 (1 year). Set to 0 to disable. -matrix_rustpush_bridge_initial_sync_days: 0 +matrix_rustpush_bridge_initial_sync_days: 365 # Shared secret for authentication of provisioning API requests. # If set to "disable", the provisioning API will be disabled. From 71579572705ed93207d12039c64832e0e39a3e7b Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sat, 30 May 2026 18:46:14 -0700 Subject: [PATCH 11/23] Make config directory non-ro --- .../templates/systemd/matrix-rustpush-bridge.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 index 339599fa4..388707f05 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 @@ -23,7 +23,7 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ --network={{ matrix_rustpush_bridge_container_network }} \ - --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config,ro \ + --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config \ --mount type=bind,src={{ matrix_rustpush_bridge_data_path }},dst=/data \ --label-file={{ matrix_rustpush_bridge_base_path }}/labels \ --entrypoint /usr/local/bin/matrix-rustpush \ From b3879ccc8d1ef2634acb403abd14d1e3d7bac133 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sat, 30 May 2026 19:13:22 -0700 Subject: [PATCH 12/23] Add data folder mount for on-disk files --- .../templates/systemd/matrix-rustpush-bridge.service.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 index 388707f05..8cc393ba2 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 @@ -23,6 +23,7 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ --network={{ matrix_rustpush_bridge_container_network }} \ + --env HOME=/data \ --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config \ --mount type=bind,src={{ matrix_rustpush_bridge_data_path }},dst=/data \ --label-file={{ matrix_rustpush_bridge_base_path }}/labels \ From 3a70e8c6026afdf3c1101ef8b757e200e2f0bf3e Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Sat, 30 May 2026 20:43:33 -0700 Subject: [PATCH 13/23] Add rust logging variable --- .../custom/matrix-bridge-rustpush/defaults/main.yml | 13 +++++++++++++ .../matrix-bridge-rustpush/tasks/setup_install.yml | 3 +++ .../systemd/matrix-rustpush-bridge.service.j2 | 1 + 3 files changed, 17 insertions(+) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index 57c674b47..26ee09c95 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -93,6 +93,19 @@ matrix_rustpush_bridge_container_labels_additional_labels: '' # A list of extra arguments to pass to the container matrix_rustpush_bridge_container_extra_arguments: [] +# Override the Rust log filter passed to the bridge container via RUST_LOG. +# Leave empty to use the bridge's built-in default +# ("warn,rustpush=warn,rustpushgo=info,open_absinthe=info"). +# +# Useful values: +# "warn,rustpushgo=info,open_absinthe=debug" # NAC emulator diagnostics (_enc field sizes, etc.) +# "warn,rustpushgo=info,open_absinthe=debug,rustpush=info" # + upstream rustpush internals +# "debug" # everything (very chatty) +# +# The open_absinthe crate logs NAC hardware-key diagnostics at INFO and emulator +# state at DEBUG. These are suppressed by default to reduce log noise. +matrix_rustpush_bridge_rust_log: "" + # List of systemd services that matrix-rustpush-bridge.service depends on. matrix_rustpush_bridge_systemd_required_services_list: "{{ matrix_rustpush_bridge_systemd_required_services_list_default + matrix_rustpush_bridge_systemd_required_services_list_auto + matrix_rustpush_bridge_systemd_required_services_list_custom }}" matrix_rustpush_bridge_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" diff --git a/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml index ebd9d28e0..918e79051 100644 --- a/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml @@ -47,6 +47,9 @@ dockerfile: Dockerfile path: "{{ matrix_rustpush_bridge_docker_src_files_path }}" pull: true + args: + BUILD_VERSION: "{{ matrix_rustpush_bridge_container_image_self_build_repo_version }}" + BUILD_COMMIT: "{{ matrix_rustpush_bridge_git_pull_results.after[:8] if matrix_rustpush_bridge_git_pull_results is defined and matrix_rustpush_bridge_git_pull_results.after is defined else 'unknown' }}" register: matrix_rustpush_bridge_container_image_build_result when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build | bool" diff --git a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 index 8cc393ba2..c52fbae84 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 @@ -24,6 +24,7 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --cap-drop=ALL \ --network={{ matrix_rustpush_bridge_container_network }} \ --env HOME=/data \ + {% if matrix_rustpush_bridge_rust_log %}--env RUST_LOG={{ matrix_rustpush_bridge_rust_log }} \{% endif %} --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config \ --mount type=bind,src={{ matrix_rustpush_bridge_data_path }},dst=/data \ --label-file={{ matrix_rustpush_bridge_base_path }}/labels \ From 89ff5cba318a0dab72d8ed31d035b34746e90ae5 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Mon, 1 Jun 2026 12:58:39 -0700 Subject: [PATCH 14/23] Fix displayname template to append (iMessage) suffix --- .../custom/matrix-bridge-rustpush/defaults/main.yml | 2 +- .../matrix-bridge-rustpush/tasks/setup_install.yml | 13 ++++++++++++- .../systemd/matrix-rustpush-bridge.service.j2 | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index 26ee09c95..330723c29 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -38,7 +38,7 @@ matrix_rustpush_bridge_appservice_public_address: '' # Displayname template for iMessage contacts. # Available variables: {{.FirstName}}, {{.LastName}}, {{.Nickname}}, # {{.Phone}}, {{.Email}}, {{.ID}} -matrix_rustpush_bridge_network_displayname_template: "{% raw %}{{if .FirstName}}{{.FirstName}}{{if .LastName}} {{.LastName}}{{end}}{{else if .Nickname}}{{.Nickname}}{{else if .Phone}}{{.Phone}}{{else if .Email}}{{.Email}}{{else}}{{.ID}}{{end}}{% endraw %}" +matrix_rustpush_bridge_network_displayname_template: "{% raw %}{{if .FirstName}}{{.FirstName}}{{if .LastName}} {{.LastName}}{{end}}{{else if .Nickname}}{{.Nickname}}{{else if .Phone}}{{.Phone}}{{else if .Email}}{{.Email}}{{else}}{{.ID}}{{end}} (iMessage){% endraw %}" matrix_rustpush_bridge_cloudkit_backfill: true matrix_rustpush_bridge_video_transcoding: true diff --git a/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml index 918e79051..45c56dc50 100644 --- a/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml @@ -64,11 +64,22 @@ - name: Ensure rustpush-bridge config.yaml installed ansible.builtin.copy: - content: "{{ matrix_rustpush_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}" + content: >- + {{ + matrix_rustpush_bridge_configuration + | combine({ + 'network': { + 'displayname_template': matrix_rustpush_bridge_network_displayname_template_effective, + }, + }, recursive=True) + | to_nice_yaml(indent=2, width=999999) + }} dest: "{{ matrix_rustpush_bridge_config_path }}/config.yaml" mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + vars: + matrix_rustpush_bridge_network_displayname_template_effective: "{{ (matrix_rustpush_bridge_configuration.network | default({}, true)).displayname_template | default(matrix_rustpush_bridge_network_displayname_template) }}" register: matrix_rustpush_bridge_config_result - name: Ensure rustpush-bridge registration.yaml installed diff --git a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 index c52fbae84..dc7a1679b 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2 @@ -24,8 +24,8 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --cap-drop=ALL \ --network={{ matrix_rustpush_bridge_container_network }} \ --env HOME=/data \ - {% if matrix_rustpush_bridge_rust_log %}--env RUST_LOG={{ matrix_rustpush_bridge_rust_log }} \{% endif %} - --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config \ +{% if matrix_rustpush_bridge_rust_log %} --env RUST_LOG={{ matrix_rustpush_bridge_rust_log }} \ +{% endif %} --mount type=bind,src={{ matrix_rustpush_bridge_config_path }},dst=/config \ --mount type=bind,src={{ matrix_rustpush_bridge_data_path }},dst=/data \ --label-file={{ matrix_rustpush_bridge_base_path }}/labels \ --entrypoint /usr/local/bin/matrix-rustpush \ From 8561ce358d1e81f26403fa221cdb515b28000ad7 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Mon, 1 Jun 2026 18:21:06 -0700 Subject: [PATCH 15/23] Add variable for appservice username template --- roles/custom/matrix-bridge-rustpush/defaults/main.yml | 4 ++++ roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index 330723c29..df70a58cd 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -151,6 +151,10 @@ matrix_rustpush_bridge_appservice_bot_username: imessagebot matrix_rustpush_bridge_appservice_bot_displayname: iMessage bridge bot matrix_rustpush_bridge_appservice_bot_avatar: '' +# Localpart template for MXIDs of remote (iMessage) users. +# The `{{.}}` placeholder expands to the iMessage handle (phone/email). +matrix_rustpush_bridge_appservice_username_template: "{% raw %}imessage_{{.}}{% endraw %}" + # Backfill is disabled by default because Linux Docker cannot access chat.db. # On macOS with Full Disk Access, this can be set to true. matrix_rustpush_bridge_backfill_enabled: false diff --git a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 index 912cac44c..d3c064842 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2 @@ -126,7 +126,7 @@ appservice: hs_token: {{ matrix_rustpush_bridge_homeserver_token | to_json }} # Localpart template of MXIDs for remote users. - username_template: "{% raw %}imessage_{{.}}{% endraw %}" + username_template: {{ matrix_rustpush_bridge_appservice_username_template | to_json }} # Config options that affect the Matrix connector of the bridge. matrix: From 59e5e2cfe5f1ad0f9f62d85b566468149a0297d1 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Mon, 1 Jun 2026 18:51:51 -0700 Subject: [PATCH 16/23] bridge docs draft --- docs/configuring-playbook-bridge-rustpush.md | 31 +++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/configuring-playbook-bridge-rustpush.md b/docs/configuring-playbook-bridge-rustpush.md index 66e435d19..d3e85e208 100644 --- a/docs/configuring-playbook-bridge-rustpush.md +++ b/docs/configuring-playbook-bridge-rustpush.md @@ -4,11 +4,11 @@ SPDX-FileCopyrightText: 2025 MDAD project contributors SPDX-License-Identifier: AGPL-3.0-or-later --> -# Setting up RustPush bridging (optional) +# Setting up RustPush (iMessage) bridging (optional) Refer the common guide for configuring mautrix bridges: [Setting up a Generic Mautrix Bridge](configuring-playbook-bridge-mautrix-bridges.md) -The playbook can install and configure [rustpush to bridge iMessage](https://github.com/jasonlaguidice/imessage) for you using Apple's push notification service (no Mac needed at runtime). +The playbook can install and configure [rustpush to bridge iMessage](https://github.com/jasonlaguidice/imessage) for you using Apple's push notification service. See the project's [documentation](https://github.com/jasonlaguidice/imessage/blob/main/README.md) to learn what it does and why it might be useful to you. @@ -20,6 +20,12 @@ To use this bridge on Linux (Docker), you need a **hardware key** extracted from The key is entered interactively through the bridge bot's login flow (not configured via Ansible variables). See the upstream [README](https://github.com/jasonlaguidice/imessage/blob/main/README.md) for instructions on extracting the key. +If extracted from an Intel Mac, the Mac does not need to remain running after the key is extracted for this bridge to work. Apple Silicon Macs must run a NAC relay. + +### Phone Number Registration (optional) + +This bridge can **not** do phone number registration (PNR). The only way to have your phone number registered and used (instead of an Apple ID e-mail address) is to have an iPhone connected to your Apple account. Reference the [BlueBubbles Phone Number Registration Guide](https://docs.bluebubbles.app/server/advanced/registering-a-phone-number-with-your-imessage-account) for information on how to set this up. + ### Enable Appservice Double Puppet (optional) If you want to set up [Double Puppeting](https://docs.mau.fi/bridges/general/double-puppeting.html) (hint: you most likely do) for this bridge automatically, you need to have enabled [Appservice Double Puppet](configuring-playbook-appservice-double-puppet.md) service for this playbook. @@ -34,15 +40,15 @@ To enable the bridge, add the following configuration to your `inventory/host_va matrix_rustpush_bridge_enabled: true ``` -### Backfill (optional) +### Disable Backfill (optional) -Backfill can be disabled globally if desired via config. Backfill from chat.db is disabled Linux Docker cannot access the macOS `chat.db` file. +Backfill can be disabled globally if desired via config. By default, the bridge will backfill from iCloud (CloudKit) and APNS if available. Backfill from `chat.db` is only possible when the bridge is running on MacOS. ```yaml matrix_rustpush_bridge_backfill_enabled: false ``` -### Extending the configuration +### Extending the Configuration There are some additional things you may wish to configure about the bridge. @@ -63,14 +69,22 @@ ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start `just install-all` is useful for maintaining your setup quickly ([2x-5x faster](../CHANGELOG.md#2x-5x-performance-improvements-in-playbook-runtime) than `just setup-all`) when its components remain unchanged. If you adjust your `vars.yml` to remove other components, you'd need to run `just setup-all`, or these components will still remain installed. -- The first run will take longer than usual because the Docker image is built from source (Rust + Go compilation). - ## Usage To use the bridge, you need to start a chat with `@imessagebot:example.com` (where `example.com` is your base domain, not the `matrix.` domain). After logging in, the bridge will start receiving iMessages and creating portal rooms. +## Interference With Mautrix-iMessage & WSproxy + +By default, this bridge uses the same bot user name (`@imessagebot:example.com`) and same localpart for puppet users (`imessage_{{.}}`) as the mautrix-imessage bridge. If you use this bridge on your homeserver have a few options: + +1. Change the bot and appservice name templates: + + Set `matrix_rustpush_bridge_appservice_bot_username` and to a non-default value `matrix_rustpush_bridge_appservice_username_template` + +2. After deactivating mautrix-imessage, delete the bot user and all its portal rooms from the database, then re-start the server (more difficult) + ## Troubleshooting As with all other services, you can find the logs in [systemd-journald](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html) by logging in to the server with SSH and running `journalctl -fu matrix-rustpush-bridge`. @@ -82,4 +96,7 @@ The default logging level for this component is `warn`. If you want to increase ```yaml # Valid values: fatal, error, warn, info, debug, trace matrix_rustpush_bridge_logging_level: 'debug' + +# Enable debug logging for RustPush +matrix_rustpush_bridge_rust_log: "warn,rustpushgo=info,openabsinthe=debug" ``` From 1e878d52ac871f87543d20d8af2ad23be72d3099 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Mon, 1 Jun 2026 19:17:33 -0700 Subject: [PATCH 17/23] Typo fix --- docs/configuring-playbook-bridge-rustpush.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuring-playbook-bridge-rustpush.md b/docs/configuring-playbook-bridge-rustpush.md index d3e85e208..c5649fd23 100644 --- a/docs/configuring-playbook-bridge-rustpush.md +++ b/docs/configuring-playbook-bridge-rustpush.md @@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later Refer the common guide for configuring mautrix bridges: [Setting up a Generic Mautrix Bridge](configuring-playbook-bridge-mautrix-bridges.md) -The playbook can install and configure [rustpush to bridge iMessage](https://github.com/jasonlaguidice/imessage) for you using Apple's push notification service. +The playbook can install and configure [rustpush bridge to iMessage](https://github.com/jasonlaguidice/imessage) for you using Apple's push notification service. See the project's [documentation](https://github.com/jasonlaguidice/imessage/blob/main/README.md) to learn what it does and why it might be useful to you. From 9227c960853c5e927751c515f0b72a653fe26feb Mon Sep 17 00:00:00 2001 From: Jason LaGuidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Mon, 1 Jun 2026 22:04:49 -0700 Subject: [PATCH 18/23] Apply suggestion from @luixxiul Co-authored-by: Suguru Hirahara --- docs/configuring-playbook-bridge-rustpush.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuring-playbook-bridge-rustpush.md b/docs/configuring-playbook-bridge-rustpush.md index c5649fd23..8b4a7e6f8 100644 --- a/docs/configuring-playbook-bridge-rustpush.md +++ b/docs/configuring-playbook-bridge-rustpush.md @@ -1,5 +1,5 @@ From 281d1103b609aefec1350878262aa8e1a9006c7d Mon Sep 17 00:00:00 2001 From: Jason LaGuidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Mon, 1 Jun 2026 22:04:56 -0700 Subject: [PATCH 19/23] Apply suggestion from @luixxiul Co-authored-by: Suguru Hirahara --- docs/configuring-playbook-bridge-rustpush.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/configuring-playbook-bridge-rustpush.md b/docs/configuring-playbook-bridge-rustpush.md index 8b4a7e6f8..109d90c9c 100644 --- a/docs/configuring-playbook-bridge-rustpush.md +++ b/docs/configuring-playbook-bridge-rustpush.md @@ -1,5 +1,6 @@ From 3dc84c19997f789512142ac445578d5991b433ac Mon Sep 17 00:00:00 2001 From: Jason LaGuidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Mon, 1 Jun 2026 22:06:49 -0700 Subject: [PATCH 20/23] Update main.yml --- roles/custom/matrix-bridge-rustpush/tasks/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/custom/matrix-bridge-rustpush/tasks/main.yml b/roles/custom/matrix-bridge-rustpush/tasks/main.yml index 5afa35fa5..ffe8ac3f3 100644 --- a/roles/custom/matrix-bridge-rustpush/tasks/main.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/main.yml @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors +# SPDX-FileCopyrightText: 2026 MDAD project contributors +# SPDX-FileCopyrightText: 2026 Jason LaGuidice # # SPDX-License-Identifier: AGPL-3.0-or-later From 3b2f5bd61f15a6a7d1ec607aab4ee31940be4f07 Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Tue, 2 Jun 2026 16:03:55 -0700 Subject: [PATCH 21/23] Add v0.0.1 version tag for MDAD --- roles/custom/matrix-bridge-rustpush/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index df70a58cd..90306c613 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -13,7 +13,7 @@ matrix_rustpush_bridge_container_image_self_build_repo: "https://github.com/jaso matrix_rustpush_bridge_container_image_self_build_repo_version: "{{ 'master' if matrix_rustpush_bridge_version == 'latest' else matrix_rustpush_bridge_version }}" # Adjust to pin to releases -matrix_rustpush_bridge_version: latest +matrix_rustpush_bridge_version: v0.0.1 matrix_rustpush_bridge_docker_image: "{{ matrix_rustpush_bridge_docker_image_registry_prefix }}jasonlaguidice/imessage:{{ matrix_rustpush_bridge_version }}" matrix_rustpush_bridge_docker_image_registry_prefix: "ghcr.io/" matrix_rustpush_bridge_docker_image_force_pull: "{{ matrix_rustpush_bridge_docker_image.endswith(':latest') }}" From 6ce319c1339e78bc28c4112dd807a681cf4dd47f Mon Sep 17 00:00:00 2001 From: jasonlaguidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Tue, 2 Jun 2026 16:04:21 -0700 Subject: [PATCH 22/23] Update documentation and license headers --- README.md | 1 + docs/configuring-playbook.md | 2 ++ docs/container-images.md | 1 + roles/custom/matrix-bridge-rustpush/defaults/main.yml | 3 ++- roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml | 3 ++- roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml | 3 ++- roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml | 3 ++- roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 | 3 ++- .../matrix-bridge-rustpush/templates/Dockerfile.j2.license | 3 ++- .../matrix-bridge-rustpush/templates/config.yaml.j2.license | 3 ++- roles/custom/matrix-bridge-rustpush/templates/labels.j2 | 3 ++- .../custom/matrix-bridge-rustpush/templates/labels.j2.license | 3 ++- .../systemd/matrix-rustpush-bridge.service.j2.license | 3 ++- 13 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5adf9c26d..9c9bbc1df 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ Bridges can be used to connect your Matrix installation with third-party communi | [mautrix-gmessages](https://github.com/mautrix/gmessages) | ❌ | Bridge to [Google Messages](https://messages.google.com/) | [Link](docs/configuring-playbook-bridge-mautrix-gmessages.md) | | [mautrix-whatsapp](https://github.com/mautrix/whatsapp) | ❌ | Bridge to [WhatsApp](https://www.whatsapp.com/) | [Link](docs/configuring-playbook-bridge-mautrix-whatsapp.md) | | [mautrix-wsproxy](https://github.com/mautrix/wsproxy) | ❌ | Bridge to Android SMS or Apple iMessage | [Link](docs/configuring-playbook-bridge-mautrix-wsproxy.md) | +| [matrix-rustpush-bridge](https://github.com/jasonlaguidice/imessage) | ❌ | Bridge to [iMessage](https://support.apple.com/messages) via Apple Push Notification service | [Link](docs/configuring-playbook-bridge-rustpush.md) | | [mautrix-bluesky](https://github.com/mautrix/bluesky) | ❌ | Bridge to [Bluesky](https://bsky.social/) | [Link](docs/configuring-playbook-bridge-mautrix-bluesky.md) | | [mautrix-twitter](https://github.com/mautrix/twitter) | ❌ | Bridge to [Twitter](https://twitter.com/) | [Link](docs/configuring-playbook-bridge-mautrix-twitter.md) | | [mautrix-googlechat](https://github.com/mautrix/googlechat) | ❌ | Bridge to [Google Chat](https://en.wikipedia.org/wiki/Google_Chat) | [Link](docs/configuring-playbook-bridge-mautrix-googlechat.md) | diff --git a/docs/configuring-playbook.md b/docs/configuring-playbook.md index 9593fd46b..ed1ce0fc6 100644 --- a/docs/configuring-playbook.md +++ b/docs/configuring-playbook.md @@ -158,6 +158,8 @@ Bridges can be used to connect your Matrix installation with third-party communi - [Setting up Mautrix wsproxy for bridging Android SMS or Apple iMessage](configuring-playbook-bridge-mautrix-wsproxy.md) +- [Setting up RustPush (iMessage) bridging](configuring-playbook-bridge-rustpush.md) + - [Setting up Appservice IRC bridging](configuring-playbook-bridge-appservice-irc.md) - [Setting up Appservice Discord bridging](configuring-playbook-bridge-appservice-discord.md) diff --git a/docs/container-images.md b/docs/container-images.md index 7e1c5dc16..bc8624f10 100644 --- a/docs/container-images.md +++ b/docs/container-images.md @@ -107,6 +107,7 @@ Bridges can be used to connect your Matrix installation with third-party communi | [Heisenbridge](configuring-playbook-bridge-heisenbridge.md) | [hif1/heisenbridge](https://hub.docker.com/r/hif1/heisenbridge) | ❌ | Bouncer-style bridge to [IRC](https://wikipedia.org/wiki/Internet_Relay_Chat) | | [mx-puppet-groupme](configuring-playbook-bridge-mx-puppet-groupme.md) | [xangelix/mx-puppet-groupme](https://hub.docker.com/r/xangelix/mx-puppet-groupme) | ❌ | Bridge to [GroupMe](https://groupme.com/) | | [matrix-steam-bridge](configuring-playbook-bridge-steam.md) | [jasonlaguidice/matrix-steam-bridge](https://github.com/jasonlaguidice/matrix-steam-bridge/pkgs/container/matrix-steam-bridge) | ❌ | Bridge to [Steam](https://steampowered.com/) | +| [matrix-rustpush-bridge](configuring-playbook-bridge-rustpush.md) | [jasonlaguidice/imessage](https://github.com/jasonlaguidice/imessage/pkgs/container/imessage) | ❌ | Bridge to [iMessage](https://support.apple.com/messages) via Apple Push Notification service | | [mx-puppet-steam](configuring-playbook-bridge-mx-puppet-steam.md) | [icewind1991/mx-puppet-steam](https://hub.docker.com/r/icewind1991/mx-puppet-steam) | ❌ | Bridge to [Steam](https://steamapp.com/) | | [Postmoogle](configuring-playbook-bridge-postmoogle.md) | [etke.cc/postmoogle](https://github.com/etkecc/postmoogle/container_registry) | ❌ | Email to Matrix bridge | diff --git a/roles/custom/matrix-bridge-rustpush/defaults/main.yml b/roles/custom/matrix-bridge-rustpush/defaults/main.yml index 90306c613..757d1de89 100644 --- a/roles/custom/matrix-bridge-rustpush/defaults/main.yml +++ b/roles/custom/matrix-bridge-rustpush/defaults/main.yml @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors +# SPDX-FileCopyrightText: 2026 MDAD project contributors +# SPDX-FileCopyrightText: 2026 Jason LaGuidice # # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml index 45c56dc50..2edbefe66 100644 --- a/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/setup_install.yml @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors +# SPDX-FileCopyrightText: 2026 MDAD project contributors +# SPDX-FileCopyrightText: 2026 Jason LaGuidice # # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml b/roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml index 26a5d04e6..c11af52a9 100644 --- a/roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/setup_uninstall.yml @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors +# SPDX-FileCopyrightText: 2026 MDAD project contributors +# SPDX-FileCopyrightText: 2026 Jason LaGuidice # # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml b/roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml index 99011123f..305142299 100644 --- a/roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml +++ b/roles/custom/matrix-bridge-rustpush/tasks/validate_config.yml @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: 2025 MDAD project contributors +# SPDX-FileCopyrightText: 2026 MDAD project contributors +# SPDX-FileCopyrightText: 2026 Jason LaGuidice # # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 index 49185aef4..dc2b97089 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2 @@ -1,5 +1,6 @@ {# -SPDX-FileCopyrightText: 2025 MDAD project contributors +SPDX-FileCopyrightText: 2026 MDAD project contributors +SPDX-FileCopyrightText: 2026 Jason LaGuidice SPDX-License-Identifier: AGPL-3.0-or-later #} diff --git a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2.license b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2.license index 826be4a75..ff5b39cd7 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2.license +++ b/roles/custom/matrix-bridge-rustpush/templates/Dockerfile.j2.license @@ -1,3 +1,4 @@ -SPDX-FileCopyrightText: 2025 MDAD project contributors +SPDX-FileCopyrightText: 2026 MDAD project contributors +SPDX-FileCopyrightText: 2026 Jason LaGuidice SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2.license b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2.license index 826be4a75..ff5b39cd7 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2.license +++ b/roles/custom/matrix-bridge-rustpush/templates/config.yaml.j2.license @@ -1,3 +1,4 @@ -SPDX-FileCopyrightText: 2025 MDAD project contributors +SPDX-FileCopyrightText: 2026 MDAD project contributors +SPDX-FileCopyrightText: 2026 Jason LaGuidice SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-rustpush/templates/labels.j2 b/roles/custom/matrix-bridge-rustpush/templates/labels.j2 index 0b42e56be..97f9b452a 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/labels.j2 +++ b/roles/custom/matrix-bridge-rustpush/templates/labels.j2 @@ -1,5 +1,6 @@ {# -SPDX-FileCopyrightText: 2025 MDAD project contributors +SPDX-FileCopyrightText: 2026 MDAD project contributors +SPDX-FileCopyrightText: 2026 Jason LaGuidice SPDX-License-Identifier: AGPL-3.0-or-later #} diff --git a/roles/custom/matrix-bridge-rustpush/templates/labels.j2.license b/roles/custom/matrix-bridge-rustpush/templates/labels.j2.license index 826be4a75..ff5b39cd7 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/labels.j2.license +++ b/roles/custom/matrix-bridge-rustpush/templates/labels.j2.license @@ -1,3 +1,4 @@ -SPDX-FileCopyrightText: 2025 MDAD project contributors +SPDX-FileCopyrightText: 2026 MDAD project contributors +SPDX-FileCopyrightText: 2026 Jason LaGuidice SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2.license b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2.license index 826be4a75..ff5b39cd7 100644 --- a/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2.license +++ b/roles/custom/matrix-bridge-rustpush/templates/systemd/matrix-rustpush-bridge.service.j2.license @@ -1,3 +1,4 @@ -SPDX-FileCopyrightText: 2025 MDAD project contributors +SPDX-FileCopyrightText: 2026 MDAD project contributors +SPDX-FileCopyrightText: 2026 Jason LaGuidice SPDX-License-Identifier: AGPL-3.0-or-later From 6729322cd953b74f419b072a0cb63254df143171 Mon Sep 17 00:00:00 2001 From: Jason LaGuidice <19523621+jasonlaguidice@users.noreply.github.com> Date: Tue, 2 Jun 2026 16:20:29 -0700 Subject: [PATCH 23/23] Add extra warning for early stages of bridge to docs --- docs/configuring-playbook-bridge-rustpush.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/configuring-playbook-bridge-rustpush.md b/docs/configuring-playbook-bridge-rustpush.md index 109d90c9c..8cd9ca5c5 100644 --- a/docs/configuring-playbook-bridge-rustpush.md +++ b/docs/configuring-playbook-bridge-rustpush.md @@ -6,7 +6,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later --> # Setting up RustPush (iMessage) bridging (optional) - +## \*\*\* THIS BRIDGE IS IN EARLY DEVELOPMENT \*\*\* +Be warned, here be ~~dragons~~ bugs. Your use, testing, and feedback of this bridge is appreciated. It may not be desirable to deploy this to a large number of users due to possible stability issues +
Refer the common guide for configuring mautrix bridges: [Setting up a Generic Mautrix Bridge](configuring-playbook-bridge-mautrix-bridges.md) The playbook can install and configure [rustpush bridge to iMessage](https://github.com/jasonlaguidice/imessage) for you using Apple's push notification service. @@ -17,11 +19,11 @@ See the project's [documentation](https://github.com/jasonlaguidice/imessage/blo ### Hardware Key Extraction -To use this bridge on Linux (Docker), you need a **hardware key** extracted from a real Mac. This key contains hardware identifiers needed for iMessage registration. +To use this bridge on Linux (Docker), each user needs a **hardware key** extracted from a real Mac. This key contains hardware identifiers needed for iMessage registration. Hardware keys can be shared by a number of users (approximately 20) before causing issues with Apple. The key is entered interactively through the bridge bot's login flow (not configured via Ansible variables). See the upstream [README](https://github.com/jasonlaguidice/imessage/blob/main/README.md) for instructions on extracting the key. -If extracted from an Intel Mac, the Mac does not need to remain running after the key is extracted for this bridge to work. Apple Silicon Macs must run a NAC relay. +If extracted from an Intel Mac, the Mac does not need to remain running after the key is extracted for this bridge to work. Apple Silicon Macs must run a NAC relay and thus must remain running. ### Phone Number Registration (optional)