| @@ -0,0 +1,22 @@ | |||||
| # Setting up Mautrix Whatsapp (optional) | |||||
| The playbook can install and configure [mautrix-whatsapp](https://github.com/tulir/mautrix-whatsapp) for you. | |||||
| See the project's [documentation](https://github.com/tulir/mautrix-whatsapp/wiki) to learn what it does and why it might be useful to you. | |||||
| Use the following playbook configuration: | |||||
| ```yaml | |||||
| matrix_mautrix_wsproxy_enabled: true | |||||
| matrix_mautrix_imessage_user: 'user@domain.com' | |||||
| ``` | |||||
| ## Set up Double Puppeting | |||||
| ## Usage | |||||
| You then need to start a chat with `@whatsappbot:YOUR_DOMAIN` (where `YOUR_DOMAIN` is your base domain, not the `matrix.` domain). | |||||
| @@ -14,7 +14,7 @@ matrix_mautrix_wsproxy_data_path: "{{ matrix_mautrix_wsproxy_base_path }}/data" | |||||
| matrix_mautrix_wsproxy_homeserver_address: "{{ matrix_homeserver_container_url }}" | matrix_mautrix_wsproxy_homeserver_address: "{{ matrix_homeserver_container_url }}" | ||||
| matrix_mautrix_wsproxy_homeserver_domain: "{{ matrix_domain }}" | matrix_mautrix_wsproxy_homeserver_domain: "{{ matrix_domain }}" | ||||
| matrix_mautrix_wsproxy_appservice_address: "http://matrix-mautrix-wsproxy:8080" | |||||
| matrix_mautrix_wsproxy_appservice_address: "http://matrix-mautrix-wsproxy:29331" | |||||
| # A list of extra arguments to pass to the container | # A list of extra arguments to pass to the container | ||||
| matrix_mautrix_wsproxy_container_extra_arguments: [] | matrix_mautrix_wsproxy_container_extra_arguments: [] | ||||
| @@ -28,7 +28,7 @@ matrix_mautrix_wsproxy_systemd_wanted_services_list: [] | |||||
| matrix_mautrix_wsproxy_appservice_token: '' | matrix_mautrix_wsproxy_appservice_token: '' | ||||
| matrix_mautrix_wsproxy_homeserver_token: '' | matrix_mautrix_wsproxy_homeserver_token: '' | ||||
| matrix_mautrix_wsproxy_appservice_bot_username: wsproxy | |||||
| matrix_mautrix_wsproxy_appservice_bot_username: imessagebot | |||||
| # Default mautrix-wsproxy configuration template which covers the generic use case. | # Default mautrix-wsproxy configuration template which covers the generic use case. | ||||
| # You can customize it by controlling the various variables inside it. | # You can customize it by controlling the various variables inside it. | ||||
| @@ -52,20 +52,42 @@ matrix_mautrix_wsproxy_configuration_extension: "{{ matrix_mautrix_wsproxy_confi | |||||
| # You most likely don't need to touch this variable. Instead, see `matrix_mautrix_wsproxy_configuration_yaml`. | # You most likely don't need to touch this variable. Instead, see `matrix_mautrix_wsproxy_configuration_yaml`. | ||||
| matrix_mautrix_wsproxy_configuration: "{{ matrix_mautrix_wsproxy_configuration_yaml|from_yaml|combine(matrix_mautrix_wsproxy_configuration_extension, recursive=True) }}" | matrix_mautrix_wsproxy_configuration: "{{ matrix_mautrix_wsproxy_configuration_yaml|from_yaml|combine(matrix_mautrix_wsproxy_configuration_extension, recursive=True) }}" | ||||
| # Default mautrix-wsproxy 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_mautrix_wsproxy_configuration_extension_yaml`) | |||||
| # or completely replace this variable with your own template. | |||||
| matrix_mautrix_imessage_configuration_yaml: "{{ lookup('template', 'templates/config-ios.yaml.j2') }}" | |||||
| matrix_mautrix_imessage_configuration_extension_yaml: | | |||||
| # Your custom YAML configuration goes here. | |||||
| # This configuration extends the default starting configuration (`matrix_mautrix_wsproxy_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_mautrix_imessage_configuration_yaml`. | |||||
| matrix_mautrix_imessage_configuration_extension: "{{ matrix_mautrix_imessage_configuration_extension_yaml|from_yaml if matrix_mautrix_imessage_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_mautrix_imessage_configuration_yaml`. | |||||
| matrix_mautrix_imessage_configuration: "{{ matrix_mautrix_imessage_configuration_yaml|from_yaml|combine(matrix_mautrix_imessage_configuration_extension, recursive=True) }}" | |||||
| matrix_mautrix_imessage_user: '' | |||||
| matrix_mautrix_wsproxy_registration_yaml: | | matrix_mautrix_wsproxy_registration_yaml: | | ||||
| id: wsproxy | |||||
| id: imessage | |||||
| url: {{ matrix_mautrix_wsproxy_appservice_address }} | url: {{ matrix_mautrix_wsproxy_appservice_address }} | ||||
| as_token: "{{ matrix_mautrix_wsproxy_appservice_token }}" | as_token: "{{ matrix_mautrix_wsproxy_appservice_token }}" | ||||
| hs_token: "{{ matrix_mautrix_wsproxy_homeserver_token }}" | hs_token: "{{ matrix_mautrix_wsproxy_homeserver_token }}" | ||||
| # See https://github.com/tulir/mautrix-signal/issues/43 | |||||
| sender_localpart: _bot_{{ matrix_mautrix_wsproxy_appservice_bot_username }} | sender_localpart: _bot_{{ matrix_mautrix_wsproxy_appservice_bot_username }} | ||||
| rate_limited: false | rate_limited: false | ||||
| namespaces: | namespaces: | ||||
| users: | users: | ||||
| - regex: '^@wsproxy_[0-9]+:{{ matrix_mautrix_wsproxy_homeserver_domain|regex_escape }}$' | |||||
| - regex: '@imessage_.+:{{ matrix_mautrix_wsproxy_homeserver_domain|regex_escape }}$' | |||||
| exclusive: true | exclusive: true | ||||
| - exclusive: true | - exclusive: true | ||||
| regex: '^@{{ matrix_mautrix_wsproxy_appservice_bot_username|regex_escape }}:{{ matrix_mautrix_wsproxy_homeserver_domain|regex_escape }}$' | regex: '^@{{ matrix_mautrix_wsproxy_appservice_bot_username|regex_escape }}:{{ matrix_mautrix_wsproxy_homeserver_domain|regex_escape }}$' | ||||
| de.sorunome.msc2409.push_ephemeral: true | |||||
| matrix_mautrix_wsproxy_registration: "{{ matrix_mautrix_wsproxy_registration_yaml|from_yaml }}" | matrix_mautrix_wsproxy_registration: "{{ matrix_mautrix_wsproxy_registration_yaml|from_yaml }}" | ||||
| @@ -28,7 +28,7 @@ | |||||
| with_items: | with_items: | ||||
| - "{{ matrix_mautrix_wsproxy_base_path }}" | - "{{ matrix_mautrix_wsproxy_base_path }}" | ||||
| - "{{ matrix_mautrix_wsproxy_config_path }}" | - "{{ matrix_mautrix_wsproxy_config_path }}" | ||||
| - "{{ matrix_mautrix_wsproxy_data_path }}" | |||||
| - "{{ matrix_mautrix_wsproxy_data_path }}" | |||||
| - name: Check if an old matrix state file exists | - name: Check if an old matrix state file exists | ||||
| stat: | stat: | ||||
| @@ -43,6 +43,14 @@ | |||||
| owner: "{{ matrix_user_username }}" | owner: "{{ matrix_user_username }}" | ||||
| group: "{{ matrix_user_groupname }}" | group: "{{ matrix_user_groupname }}" | ||||
| - name: Ensure mautrix-imessage config-ios.yaml installed | |||||
| copy: | |||||
| content: "{{ matrix_mautrix_imessage_configuration|to_nice_yaml }}" | |||||
| dest: "{{ matrix_mautrix_wsproxy_config_path }}/config-ios.yaml" | |||||
| mode: 0644 | |||||
| owner: "{{ matrix_user_username }}" | |||||
| group: "{{ matrix_user_groupname }}" | |||||
| - name: Ensure mautrix-wsproxy registration.yaml installed | - name: Ensure mautrix-wsproxy registration.yaml installed | ||||
| copy: | copy: | ||||
| content: "{{ matrix_mautrix_wsproxy_registration|to_nice_yaml }}" | content: "{{ matrix_mautrix_wsproxy_registration|to_nice_yaml }}" | ||||
| @@ -0,0 +1,107 @@ | |||||
| #jinja2: lstrip_blocks: "True" | |||||
| # Homeserver details. | |||||
| homeserver: | |||||
| # The address that this appservice can use to connect to the homeserver. | |||||
| address: {{ matrix_mautrix_wsproxy_homeserver_domain }} | |||||
| websocket_proxy: {{ matrix_mautrix_wsproxy_appservice_address }} | |||||
| # The domain of the homeserver (for MXIDs, etc). | |||||
| domain: {{ matrix_mautrix_wsproxy_homeserver_domain }} | |||||
| # Application service host/registration related details. | |||||
| # Changing these values requires regeneration of the registration. | |||||
| appservice: | |||||
| # SQLite database path | |||||
| database: mautrix-imessage.db | |||||
| # The unique ID of this appservice. | |||||
| id: imessage | |||||
| # Appservice bot details. | |||||
| bot: | |||||
| # Username of the appservice bot. | |||||
| username: imessagebot | |||||
| # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty | |||||
| # to leave display name/avatar as-is. | |||||
| displayname: iMessage bridge bot | |||||
| avatar: mxc://maunium.net/tManJEpANASZvDVzvRvhILdX | |||||
| # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify. | |||||
| as_token: "This value is generated when generating the registration" | |||||
| hs_token: "This value is generated when generating the registration" | |||||
| imessage: | |||||
| platform: ios | |||||
| # Bridge config | |||||
| bridge: | |||||
| # The user of the bridge. | |||||
| user: "{{ matrix_mautrix_imessage_user }}" | |||||
| # Localpart template of MXIDs for iMessage users. | |||||
| # {{ '{{.}}' }} is replaced with the phone number or email of the iMessage user. | |||||
| username_template: "{{ 'imessage_{{.}}' }}" | |||||
| # Displayname template for iMessage users. | |||||
| # {{ '{{.}}' }} is replaced with the contact list name (if available) or username (phone number or email) of the iMessage user. | |||||
| displayname_template: "{{ '{{.}} (iMessage)' }}" | |||||
| # Whether or not the bridge should send a read receipt from the bridge bot when a message has been | |||||
| # sent to iMessage. If fetch_message_on_timeout is enabled, a successful post-timeout fetch will | |||||
| # trigger a read receipt too. | |||||
| delivery_receipts: false | |||||
| # Whether or not to update the m.direct account data event when double puppeting is enabled. | |||||
| # Note that updating the m.direct event is not atomic (except with mautrix-asmux) | |||||
| # and is therefore prone to race conditions. | |||||
| sync_direct_chat_list: false | |||||
| # Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth | |||||
| # | |||||
| # If set, custom puppets will be enabled automatically for local users | |||||
| # instead of users having to find an access token and run `login-matrix` | |||||
| # manually. | |||||
| login_shared_secret: {{ matrix_mautrix_whatsapp_login_shared_secret|to_json }} | |||||
| # Maximum age of chats to sync in days. | |||||
| chat_sync_max_age: 0.5 | |||||
| # Maximum number of messages to backfill for new portal rooms. | |||||
| initial_backfill_limit: 100 | |||||
| # The prefix for commands. Only required in non-management rooms. | |||||
| command_prefix: "!im" | |||||
| # End-to-bridge encryption support options. This requires login_shared_secret to be configured | |||||
| # in order to get a device for the bridge bot. | |||||
| # | |||||
| # Additionally, https://github.com/matrix-org/synapse/pull/5758 is required if using a normal | |||||
| # application service. | |||||
| encryption: | |||||
| # Allow encryption, work in group chat rooms with e2ee enabled | |||||
| allow: false | |||||
| # Default to encryption, force-enable encryption in all portals the bridge creates | |||||
| # This will cause the bridge bot to be in private chats for the encryption to work properly. | |||||
| # It is recommended to also set private_chat_portal_meta to true when using this. | |||||
| default: false | |||||
| # Options for automatic key sharing. | |||||
| key_sharing: | |||||
| # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled. | |||||
| # You must use a client that supports requesting keys from other users to use this feature. | |||||
| allow: false | |||||
| # Require the requesting device to have a valid cross-signing signature? | |||||
| # This doesn't require that the bridge has verified the device, only that the user has verified it. | |||||
| # Not yet implemented. | |||||
| require_cross_signing: false | |||||
| # Require devices to be verified by the bridge? | |||||
| # Verification by the bridge is not yet implemented. | |||||
| require_verification: true | |||||
| # Logging config. | |||||
| logging: | |||||
| # The directory for log files. Will be created if not found. | |||||
| directory: ./logs | |||||
| # Available variables: .Date for the file date and .Index for different log files on the same day. | |||||
| file_name_format: "{{ '{{.Date}}-{{.Index}}.log' }}" | |||||
| # Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants | |||||
| file_date_format: "2006-01-02" | |||||
| # Log file permissions. | |||||
| file_mode: 0600 | |||||
| # Timestamp format for log entries in the Go time format. | |||||
| timestamp_format: "Jan _2, 2006 15:04:05" | |||||
| # Minimum severity for log messages. | |||||
| # Options: debug, info, warn, error, fatal | |||||
| print_level: debug | |||||
| @@ -1,5 +1,5 @@ | |||||
| listen_address: 0.0.0.0:8080 | |||||
| listen_address: 0.0.0.0:29331 | |||||
| appservices: | appservices: | ||||
| - id: iMessage | |||||
| - id: imessage | |||||
| as: "{{ matrix_mautrix_wsproxy_appservice_token }}" | as: "{{ matrix_mautrix_wsproxy_appservice_token }}" | ||||
| hs: "{{ matrix_mautrix_wsproxy_homeserver_token }}" | hs: "{{ matrix_mautrix_wsproxy_homeserver_token }}" | ||||
| @@ -26,8 +26,7 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-mautrix-wsprox | |||||
| --network={{ matrix_docker_network }} \ | --network={{ matrix_docker_network }} \ | ||||
| -v {{ matrix_mautrix_wsproxy_config_path }}:/config:z \ | -v {{ matrix_mautrix_wsproxy_config_path }}:/config:z \ | ||||
| -v {{ matrix_mautrix_wsproxy_data_path }}:/data:z \ | -v {{ matrix_mautrix_wsproxy_data_path }}:/data:z \ | ||||
| -e AS_TOKEN='{{ matrix_mautrix_wsproxy_appservice_token }}' \ | |||||
| -e HS_TOKEN='{{ matrix_mautrix_wsproxy_homeserver_token }}' \ | |||||
| -p 29331:29331 \ | |||||
| {% for arg in matrix_mautrix_wsproxy_container_extra_arguments %} | {% for arg in matrix_mautrix_wsproxy_container_extra_arguments %} | ||||
| {{ arg }} \ | {{ arg }} \ | ||||
| {% endfor %} | {% endfor %} | ||||