From 0585889d5a66bf29ee715913a20b7cf102f21dde Mon Sep 17 00:00:00 2001 From: microchipster Date: Sun, 28 Jul 2019 16:52:30 +0000 Subject: [PATCH 01/29] add hangouts bridge by copying facebook bridge and find-replacing --- group_vars/matrix_servers | 30 +++ .../defaults/main.yml | 179 ++++++++++++++++++ .../tasks/init.yml | 16 ++ .../tasks/main.yml | 21 ++ .../tasks/setup_install.yml | 73 +++++++ .../tasks/setup_uninstall.yml | 24 +++ .../tasks/validate_config.yml | 10 + .../matrix-mautrix-hangouts.service.j2 | 48 +++++ setup.yml | 1 + 9 files changed, 402 insertions(+) create mode 100644 roles/matrix-bridge-mautrix-hangouts/defaults/main.yml create mode 100644 roles/matrix-bridge-mautrix-hangouts/tasks/init.yml create mode 100644 roles/matrix-bridge-mautrix-hangouts/tasks/main.yml create mode 100644 roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml create mode 100644 roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml create mode 100644 roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml create mode 100644 roles/matrix-bridge-mautrix-hangouts/templates/systemd/matrix-mautrix-hangouts.service.j2 diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 503a45be..b08cdce5 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -123,6 +123,36 @@ matrix_mautrix_facebook_homeserver_token: "{{ matrix_synapse_macaroon_secret_key ###################################################################### +###################################################################### +# +# matrix-bridge-mautrix-hangouts +# +###################################################################### + +# We don't enable bridges by default. +matrix_mautrix_hangouts_enabled: false + +matrix_mautrix_hangouts_systemd_required_services_list: | + {{ + ['docker.service'] + + + (['matrix-synapse.service'] if matrix_synapse_enabled else []) + }} + +matrix_mautrix_hangouts_appservice_token: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'ho.as.token') | to_uuid }}" + +matrix_mautrix_hangouts_homeserver_token: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'ho.hs.token') | to_uuid }}" + +###################################################################### +# +# /matrix-bridge-mautrix-hangouts_ +# +###################################################################### + + + + + ###################################################################### # # matrix-bridge-mautrix-telegram diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml new file mode 100644 index 00000000..9687a9ae --- /dev/null +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -0,0 +1,179 @@ +# mautrix-hangouts is a Matrix <-> Hangouts bridge +# See: https://github.com/tulir/mautrix-hangouts + +matrix_mautrix_hangouts_enabled: true + +matrix_mautrix_hangouts_docker_image: "dock.mau.dev/tulir/mautrix-hangouts:latest" +matrix_mautrix_hangouts_docker_image_force_pull: "{{ matrix_mautrix_hangouts_docker_image.endswith(':latest') }}" + +matrix_mautrix_hangouts_base_path: "{{ matrix_base_data_path }}/mautrix-hangouts" +matrix_mautrix_hangouts_config_path: "{{ matrix_mautrix_hangouts_base_path }}/config" +matrix_mautrix_hangouts_data_path: "{{ matrix_mautrix_hangouts_base_path }}/data" + +matrix_mautrix_hangouts_homeserver_address: 'http://matrix-synapse:8008' +matrix_mautrix_hangouts_homeserver_domain: '{{ matrix_domain }}' +matrix_mautrix_hangouts_appservice_address: 'http://matrix-mautrix-hangouts:8080' + +# A list of extra arguments to pass to the container +matrix_mautrix_hangouts_container_extra_arguments: [] + +# List of systemd services that matrix-mautrix-hangouts.service depends on. +matrix_mautrix_hangouts_systemd_required_services_list: ['docker.service'] + +# List of systemd services that matrix-mautrix-hangouts.service wants +matrix_mautrix_hangouts_systemd_wanted_services_list: [] + +matrix_mautrix_hangouts_appservice_token: '' +matrix_mautrix_hangouts_homeserver_token: '' + +# Default mxisd 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_hangouts_configuration_extension_yaml`) +# or completely replace this variable with your own template. +matrix_mautrix_hangouts_configuration_yaml: | + #jinja2: lstrip_blocks: "True" + # Homeserver details + homeserver: + # The address that this appservice can use to connect to the homeserver. + address: {{ matrix_mautrix_hangouts_homeserver_address }} + # The domain of the homeserver (for MXIDs, etc). + domain: {{ matrix_mautrix_hangouts_homeserver_domain }} + # Whether or not to verify the SSL certificate of the homeserver. + # Only applies if address starts with https:// + verify_ssl: true + + # Application service host/registration related details + # Changing these values requires regeneration of the registration. + appservice: + # The address that the homeserver can use to connect to this appservice. + address: {{ matrix_mautrix_hangouts_appservice_address }} + + # The hostname and port where this appservice should listen. + hostname: 0.0.0.0 + port: 8080 + # The maximum body size of appservice API requests (from the homeserver) in mebibytes + # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s + max_body_size: 1 + + # The full URI to the database. SQLite and Postgres are fully supported. + # Other DBMSes supported by SQLAlchemy may or may not work. + # Format examples: + # SQLite: sqlite:///filename.db + # Postgres: postgres://username:password@hostname/dbname + database: sqlite:////data/mautrix-hangouts.db + + # The unique ID of this appservice. + id: hangouts + # Username of the appservice bot. + bot_username: hangoutsbot + # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty + # to leave display name/avatar as-is. + bot_displayname: Hangouts bridge bot + bot_avatar: mxc://maunium.net/ddtNPZSKMNqaUzqrHuWvUADv + + # Authentication tokens for AS <-> HS communication. + as_token: "{{ matrix_mautrix_hangouts_appservice_token }}" + hs_token: "{{ matrix_mautrix_hangouts_homeserver_token }}" + + # Bridge config + bridge: + # Localpart template of MXIDs for Hangouts users. + # {userid} is replaced with the user ID of the Hangouts user. + username_template: "hangouts_{userid}" + # Displayname template for Hangouts users. + # {displayname} is replaced with the display name of the Hangouts user + # as defined below in displayname_preference. + # Keys available for displayname_preference are also available here. + displayname_template: '{displayname} (HO)' + # Available keys: + # "name" (full name) + # "first_name" + # "last_name" + # "nickname" + # "own_nickname" (user-specific!) + displayname_preference: + - name + + # The prefix for commands. Only required in non-management rooms. + command_prefix: "!HO" + + # Number of chats to sync (and create portals for) on startup/login. + # Maximum 20, set 0 to disable automatic syncing. + initial_chat_sync: 10 + # Whether or not the Hangouts users of logged in Matrix users should be + # invited to private chats when the user sends a message from another client. + invite_own_puppet_to_pm: false + # Whether or not to use /sync to get presence, read receipts and typing notifications when using + # your own Matrix account as the Matrix puppet for your Hangouts account. + sync_with_custom_puppets: true + # Whether or not to bridge presence in both directions. Hangouts allows users not to broadcast + # presence, but then it won't send other users' presence to the client. + presence: true + + # Permissions for using the bridge. + # Permitted values: + # user - Use the bridge with puppeting. + # admin - Use and administrate the bridge. + # Permitted keys: + # * - All Matrix users + # domain - All users on that homeserver + # mxid - Specific user + permissions: + '{{ matrix_mautrix_hangouts_homeserver_domain }}': user + + # Python logging configuration. + # + # See section 16.7.2 of the Python documentation for more info: + # https://docs.python.org/3.6/library/logging.config.html#configuration-dictionary-schema + logging: + version: 1 + formatters: + colored: + (): mautrix_hangouts.util.ColorFormatter + format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s" + normal: + format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s" + handlers: + console: + class: logging.StreamHandler + formatter: colored + loggers: + mau: + level: DEBUG + hangouts: + level: DEBUG + aiohttp: + level: INFO + root: + level: DEBUG + handlers: [console] + +matrix_mautrix_hangouts_configuration_extension_yaml: | + # Your custom YAML configuration goes here. + # This configuration extends the default starting configuration (`matrix_mautrix_hangouts_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_hangouts_configuration_yaml`. + +matrix_mautrix_hangouts_configuration_extension: "{{ matrix_mautrix_hangouts_configuration_extension_yaml|from_yaml if matrix_mautrix_hangouts_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_hangouts_configuration_yaml`. +matrix_mautrix_hangouts_configuration: "{{ matrix_mautrix_hangouts_configuration_yaml|from_yaml|combine(matrix_mautrix_hangouts_configuration_extension, recursive=True) }}" + +matrix_mautrix_hangouts_registration_yaml: | + id: hangouts + as_token: "{{ matrix_mautrix_hangouts_appservice_token }}" + hs_token: "{{ matrix_mautrix_hangouts_homeserver_token }}" + namespaces: + users: + - exclusive: true + regex: '^@hangouts_.+:{{ matrix_mautrix_hangouts_homeserver_domain|regex_escape }}$' + url: {{ matrix_mautrix_hangouts_appservice_address }} + sender_localpart: hangoutsbot + rate_limited: false + +matrix_mautrix_hangouts_registration: "{{ matrix_mautrix_hangouts_registration_yaml|from_yaml }}" diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml new file mode 100644 index 00000000..9881398d --- /dev/null +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml @@ -0,0 +1,16 @@ +- set_fact: + matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-hangouts'] }}" + when: matrix_mautrix_hangouts_enabled|bool + +# If the matrix-synapse role is not used, these variables may not exist. +- set_fact: + matrix_synapse_container_extra_arguments: > + {{ matrix_synapse_container_extra_arguments|default([]) }} + + + {{ ["--mount type=bind,src={{ matrix_mautrix_hangouts_config_path }}/registration.yaml,dst=/matrix-mautrix-hangouts-registration.yaml,ro"] }} + + matrix_synapse_app_service_config_files: > + {{ matrix_synapse_app_service_config_files|default([]) }} + + + {{ ["/matrix-mautrix-hangouts-registration.yaml"] }} + when: matrix_mautrix_hangouts_enabled|bool diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/main.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/main.yml new file mode 100644 index 00000000..0df0d0e3 --- /dev/null +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/main.yml @@ -0,0 +1,21 @@ +- import_tasks: "{{ role_path }}/tasks/init.yml" + tags: + - always + +- import_tasks: "{{ role_path }}/tasks/validate_config.yml" + when: "run_setup|bool and matrix_mautrix_hangouts_enabled|bool" + tags: + - setup-all + - setup-mautrix-hangouts + +- import_tasks: "{{ role_path }}/tasks/setup_install.yml" + when: "run_setup|bool and matrix_mautrix_hangouts_enabled|bool" + tags: + - setup-all + - setup-mautrix-hangouts + +- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" + when: "run_setup|bool and not matrix_mautrix_hangouts_enabled|bool" + tags: + - setup-all + - setup-mautrix-hangouts diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml new file mode 100644 index 00000000..7f325165 --- /dev/null +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_install.yml @@ -0,0 +1,73 @@ +--- + +# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. +# We don't want to fail in such cases. +- name: Fail if matrix-synapse role already executed + fail: + msg: >- + The matrix-bridge-mautrix-hangouts role needs to execute before the matrix-synapse role. + when: "matrix_synapse_role_executed|default(False)" + +- name: Ensure Mautrix Hangouts image is pulled + docker_image: + name: "{{ matrix_mautrix_hangouts_docker_image }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_mautrix_hangouts_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_hangouts_docker_image_force_pull }}" + +- name: Ensure Mautrix Hangouts paths exist + file: + path: "{{ item }}" + state: directory + mode: 0750 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_username }}" + with_items: + - "{{ matrix_mautrix_hangouts_base_path }}" + - "{{ matrix_mautrix_hangouts_config_path }}" + - "{{ matrix_mautrix_hangouts_data_path }}" + +- name: Check if an old database file already exists + stat: + path: "{{ matrix_mautrix_hangouts_base_path }}/mautrix-hangouts.db" + register: matrix_mautrix_hangouts_stat_database + +- name: (Data relocation) Ensure matrix-mautrix-hangouts.service is stopped + service: + name: matrix-mautrix-hangouts + state: stopped + daemon_reload: yes + failed_when: false + when: "matrix_mautrix_hangouts_stat_database.stat.exists" + +- name: (Data relocation) Move mautrix-hangouts database file to ./data directory + command: "mv {{ matrix_mautrix_hangouts_base_path }}/mautrix-hangouts.db {{ matrix_mautrix_hangouts_data_path }}/mautrix-hangouts.db" + when: "matrix_mautrix_hangouts_stat_database.stat.exists" + +- name: Ensure mautrix-hangouts config.yaml installed + copy: + content: "{{ matrix_mautrix_hangouts_configuration|to_nice_yaml }}" + dest: "{{ matrix_mautrix_hangouts_config_path }}/config.yaml" + mode: 0644 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_username }}" + +- name: Ensure mautrix-hangouts registration.yaml installed + copy: + content: "{{ matrix_mautrix_hangouts_registration|to_nice_yaml }}" + dest: "{{ matrix_mautrix_hangouts_config_path }}/registration.yaml" + mode: 0644 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_username }}" + +- name: Ensure matrix-mautrix-hangouts.service installed + template: + src: "{{ role_path }}/templates/systemd/matrix-mautrix-hangouts.service.j2" + dest: "/etc/systemd/system/matrix-mautrix-hangouts.service" + mode: 0644 + register: matrix_mautrix_hangouts_systemd_service_result + +- name: Ensure systemd reloaded after matrix-mautrix-hangouts.service installation + service: + daemon_reload: yes + when: "matrix_mautrix_hangouts_systemd_service_result.changed" diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml new file mode 100644 index 00000000..ef33e238 --- /dev/null +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/setup_uninstall.yml @@ -0,0 +1,24 @@ +--- + +- name: Check existence of matrix-mautrix-hangouts service + stat: + path: "/etc/systemd/system/matrix-mautrix-hangouts.service" + register: matrix_mautrix_hangouts_service_stat + +- name: Ensure matrix-mautrix-hangouts is stopped + service: + name: matrix-mautrix-hangouts + state: stopped + daemon_reload: yes + when: "matrix_mautrix_hangouts_service_stat.stat.exists" + +- name: Ensure matrix-mautrix-hangouts.service doesn't exist + file: + path: "/etc/systemd/system/matrix-mautrix-hangouts.service" + state: absent + when: "matrix_mautrix_hangouts_service_stat.stat.exists" + +- name: Ensure systemd reloaded after matrix-mautrix-hangouts.service removal + service: + daemon_reload: yes + when: "matrix_mautrix_hangouts_service_stat.stat.exists" diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml new file mode 100644 index 00000000..312cfcc8 --- /dev/null +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml @@ -0,0 +1,10 @@ +--- + +- name: Fail if required settings not defined + fail: + msg: >- + You need to define a required configuration setting (`{{ item }}`). + when: "vars[item] == ''" + with_items: + - "matrix_mautrix_hangouts_appservice_token" + - "matrix_mautrix_hangouts_homeserver_token" diff --git a/roles/matrix-bridge-mautrix-hangouts/templates/systemd/matrix-mautrix-hangouts.service.j2 b/roles/matrix-bridge-mautrix-hangouts/templates/systemd/matrix-mautrix-hangouts.service.j2 new file mode 100644 index 00000000..e241db3d --- /dev/null +++ b/roles/matrix-bridge-mautrix-hangouts/templates/systemd/matrix-mautrix-hangouts.service.j2 @@ -0,0 +1,48 @@ +#jinja2: lstrip_blocks: "True" +[Unit] +Description=Matrix Mautrix Hangouts server +{% for service in matrix_mautrix_hangouts_systemd_required_services_list %} +Requires={{ service }} +After={{ service }} +{% endfor %} +{% for service in matrix_mautrix_hangouts_systemd_wanted_services_list %} +Wants={{ service }} +{% endfor %} + +[Service] +Type=simple +ExecStartPre=-/usr/bin/docker kill matrix-mautrix-hangouts +ExecStartPre=-/usr/bin/docker rm matrix-mautrix-hangouts +ExecStartPre=/usr/bin/docker run --rm --name matrix-mautrix-hangouts-db \ + --log-driver=none \ + --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + --cap-drop=ALL \ + -v {{ matrix_mautrix_hangouts_config_path }}:/config:z \ + -v {{ matrix_mautrix_hangouts_data_path }}:/data:z \ + {{ matrix_mautrix_hangouts_docker_image }} \ + alembic -x config=/config/config.yaml upgrade head + +# Intentional delay, so that the homeserver (we likely depend on) can manage to start. +ExecStartPre=/bin/sleep 5 + +ExecStart=/usr/bin/docker run --rm --name matrix-mautrix-hangouts \ + --log-driver=none \ + --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + --cap-drop=ALL \ + --network={{ matrix_docker_network }} \ + -v {{ matrix_mautrix_hangouts_config_path }}:/config:z \ + -v {{ matrix_mautrix_hangouts_data_path }}:/data:z \ + {% for arg in matrix_mautrix_hangouts_container_extra_arguments %} + {{ arg }} \ + {% endfor %} + {{ matrix_mautrix_hangouts_docker_image }} \ + python3 -m mautrix_hangouts -c /config/config.yaml + +ExecStop=-/usr/bin/docker kill matrix-mautrix-hangouts +ExecStop=-/usr/bin/docker rm matrix-mautrix-hangouts +Restart=always +RestartSec=30 +SyslogIdentifier=matrix-mautrix-hangouts + +[Install] +WantedBy=multi-user.target diff --git a/setup.yml b/setup.yml index 341840a2..5a8148d7 100755 --- a/setup.yml +++ b/setup.yml @@ -11,6 +11,7 @@ - matrix-bridge-appservice-discord - matrix-bridge-appservice-irc - matrix-bridge-mautrix-facebook + - matrix-bridge-mautrix-hangouts - matrix-bridge-mautrix-telegram - matrix-bridge-mautrix-whatsapp - matrix-synapse From a16347789da2631a55b75d074c9514890071e0d2 Mon Sep 17 00:00:00 2001 From: microchipster Date: Mon, 29 Jul 2019 16:10:35 +0000 Subject: [PATCH 02/29] nginx settings for hangouts bridge login --- .../templates/nginx/conf.d/matrix-synapse.conf.j2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 index eda0929b..c971c749 100644 --- a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 +++ b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 @@ -191,6 +191,13 @@ server { location / { rewrite ^/$ /_matrix/static/ last; } + + {% if matrix_mautrix_hangouts_enabled %} + location /login { + proxy_pass http://127.0.0.1:8080; + proxy_set_header X-Forwarded-For $remote_addr; + } + {% endif %} } {% if matrix_nginx_proxy_proxy_matrix_federation_api_enabled %} From 2d3fc98d18553731f3fb3037f8cf2a471c8efec4 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 16:53:45 -0700 Subject: [PATCH 03/29] Update main.yml --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 9687a9ae..c9a918a5 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -70,7 +70,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty # to leave display name/avatar as-is. bot_displayname: Hangouts bridge bot - bot_avatar: mxc://maunium.net/ddtNPZSKMNqaUzqrHuWvUADv + bot_avatar: mxc://maunium.net/FBXZnpfORkBEruORbikmleAy # Authentication tokens for AS <-> HS communication. as_token: "{{ matrix_mautrix_hangouts_appservice_token }}" From 4528e6402b4a962be56b29a0b27d3646a1951dc9 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 17:09:12 -0700 Subject: [PATCH 04/29] add Publicly accessible base URL for the login endpoints. # Auth server config auth: # Publicly accessible base URL for the login endpoints. # The prefix below is not implicitly added. This URL and all subpaths should be proxied # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. public: http://example.com/login/ # Internal prefix in the appservice web server for the login endpoints. prefix: /login --- .../defaults/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index c9a918a5..095e11f6 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -107,9 +107,22 @@ matrix_mautrix_hangouts_configuration_yaml: | # Whether or not to use /sync to get presence, read receipts and typing notifications when using # your own Matrix account as the Matrix puppet for your Hangouts account. sync_with_custom_puppets: true + # Whether or not to bridge presence in both directions. Hangouts allows users not to broadcast # presence, but then it won't send other users' presence to the client. presence: true + + # Public website and API configs + web: + # Auth server config + auth: + # Publicly accessible base URL for the login endpoints. + # The prefix below is not implicitly added. This URL and all subpaths should be proxied + # or otherwise pointed to the appservice's webserver to the path specified below (prefix). + # This path should usually include a trailing slash. + public: "{{ matrix_mautrix_hangouts_homeserver_domain }}login/" + # Internal prefix in the appservice web server for the login endpoints. + prefix: /login # Permissions for using the bridge. # Permitted values: From ab6e808bc62ab1bec4fc76a710e792d3e06b387b Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 17:14:25 -0700 Subject: [PATCH 05/29] fix /login for mautrix-hangouts bridge --- .../templates/nginx/conf.d/matrix-synapse.conf.j2 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 index c971c749..861aa246 100644 --- a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 +++ b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 @@ -192,12 +192,6 @@ server { rewrite ^/$ /_matrix/static/ last; } - {% if matrix_mautrix_hangouts_enabled %} - location /login { - proxy_pass http://127.0.0.1:8080; - proxy_set_header X-Forwarded-For $remote_addr; - } - {% endif %} } {% if matrix_nginx_proxy_proxy_matrix_federation_api_enabled %} @@ -218,6 +212,13 @@ server { ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }}; ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; + + {% if matrix_mautrix_hangouts_enabled %} + location /login { + proxy_pass http://matrix-mautrix-hangouts:8080; + proxy_set_header X-Forwarded-For $remote_addr; + } + {% endif %} location / { {% if matrix_nginx_proxy_enabled %} From b0f203b2ecd1c53413a49d8b69698f26fa8d13d2 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 19:56:42 -0700 Subject: [PATCH 06/29] Update main.yml --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 095e11f6..e083138c 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -120,7 +120,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # The prefix below is not implicitly added. This URL and all subpaths should be proxied # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. - public: "{{ matrix_mautrix_hangouts_homeserver_domain }}login/" + public: "{{ matrix_mautrix_hangouts_homeserver_domain }}/login/" # Internal prefix in the appservice web server for the login endpoints. prefix: /login From c71cef3f70d89b043ce94a1287b3e8d5c2d73014 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 19:58:19 -0700 Subject: [PATCH 07/29] Add hangouts /login in the right place --- .../templates/nginx/conf.d/matrix-domain.conf.j2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 index 0d234827..1c3e6e0f 100644 --- a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 +++ b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 @@ -39,6 +39,13 @@ server { ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }}; ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; + + {% if matrix_mautrix_hangouts_enabled %} + location /login { + proxy_pass http://matrix-mautrix-hangouts:8080; + proxy_set_header X-Forwarded-For $remote_addr; + } + {% endif %} location /.well-known/matrix { root {{ matrix_static_files_base_path }}; From bc1c30168c102fb78e54e58fba69b9389e88fe71 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 19:59:44 -0700 Subject: [PATCH 08/29] remove login block -- wrong file --- .../templates/nginx/conf.d/matrix-synapse.conf.j2 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 index 861aa246..1b2e0db5 100644 --- a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 +++ b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 @@ -213,12 +213,6 @@ server { ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; - {% if matrix_mautrix_hangouts_enabled %} - location /login { - proxy_pass http://matrix-mautrix-hangouts:8080; - proxy_set_header X-Forwarded-For $remote_addr; - } - {% endif %} location / { {% if matrix_nginx_proxy_enabled %} From da6d2e562150915f05b6ec2a48cd5b65d96bdaca Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 23:38:14 -0700 Subject: [PATCH 09/29] Update main.yml --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index e083138c..55876be5 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -120,7 +120,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # The prefix below is not implicitly added. This URL and all subpaths should be proxied # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. - public: "{{ matrix_mautrix_hangouts_homeserver_domain }}/login/" + public: "{{ matrix_domain }}/login/" # Internal prefix in the appservice web server for the login endpoints. prefix: /login From 451d84a98160235780949b379aabc296c354e4f4 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 29 Jul 2019 23:56:56 -0700 Subject: [PATCH 10/29] Update main.yml --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 55876be5..4ea59c01 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -154,7 +154,7 @@ matrix_mautrix_hangouts_configuration_yaml: | loggers: mau: level: DEBUG - hangouts: + hangups: level: DEBUG aiohttp: level: INFO From ef9f6efd1238dea564b509c499d639856367708a Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Tue, 30 Jul 2019 01:14:12 -0700 Subject: [PATCH 11/29] Update main.yml --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 4ea59c01..89276be8 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -120,7 +120,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # The prefix below is not implicitly added. This URL and all subpaths should be proxied # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. - public: "{{ matrix_domain }}/login/" + public: "/login/" # Internal prefix in the appservice web server for the login endpoints. prefix: /login From ad682f218088e87e1b1101b9e25d192d7fcfab2d Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Fri, 2 Aug 2019 15:24:48 -0700 Subject: [PATCH 12/29] Update main.yml --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 89276be8..4ea59c01 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -120,7 +120,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # The prefix below is not implicitly added. This URL and all subpaths should be proxied # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. - public: "/login/" + public: "{{ matrix_domain }}/login/" # Internal prefix in the appservice web server for the login endpoints. prefix: /login From 0a9ce65d3b06ac604baedf3a7813f067e5e4de83 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Fri, 2 Aug 2019 15:34:23 -0700 Subject: [PATCH 13/29] Update validate_config.yml --- roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml index 312cfcc8..16dc8e65 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml @@ -8,3 +8,5 @@ with_items: - "matrix_mautrix_hangouts_appservice_token" - "matrix_mautrix_hangouts_homeserver_token" +- debug: + msg: matrix_base: {{ matrix_base }}, matrix_mautrix_hangouts_homeserver_domain: {{ matrix_mautrix_hangouts_homeserver_domain }} From 85c7e9eb09cabf7cda5bc7e1c7794406168b60f7 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Fri, 2 Aug 2019 15:37:02 -0700 Subject: [PATCH 14/29] Update validate_config.yml --- roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml index 16dc8e65..c37a77c9 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml @@ -9,4 +9,5 @@ - "matrix_mautrix_hangouts_appservice_token" - "matrix_mautrix_hangouts_homeserver_token" - debug: - msg: matrix_base: {{ matrix_base }}, matrix_mautrix_hangouts_homeserver_domain: {{ matrix_mautrix_hangouts_homeserver_domain }} + msg: >- + matrix_base: {{ matrix_base }}, matrix_mautrix_hangouts_homeserver_domain: {{ matrix_mautrix_hangouts_homeserver_domain }} From c1aea7c3fc30f112a4e010b18d265b7a8ac340ff Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Fri, 2 Aug 2019 15:42:50 -0700 Subject: [PATCH 15/29] Update validate_config.yml --- .../matrix-bridge-mautrix-hangouts/tasks/validate_config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml index c37a77c9..31ff3d0b 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml @@ -9,5 +9,6 @@ - "matrix_mautrix_hangouts_appservice_token" - "matrix_mautrix_hangouts_homeserver_token" - debug: - msg: >- - matrix_base: {{ matrix_base }}, matrix_mautrix_hangouts_homeserver_domain: {{ matrix_mautrix_hangouts_homeserver_domain }} + msg: + - '`matrix_base` == {{ matrix_base }}' + - '`matrix_mautrix_hangouts_homeserver_domain` == {{ matrix_mautrix_hangouts_homeserver_domain }}' From 264704a29efb582bb341fbdc15d403e1ad4c6c91 Mon Sep 17 00:00:00 2001 From: microchipster Date: Tue, 30 Jul 2019 16:56:36 +0000 Subject: [PATCH 16/29] absorb Munfred changes --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 4ea59c01..48dedfc3 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -107,11 +107,11 @@ matrix_mautrix_hangouts_configuration_yaml: | # Whether or not to use /sync to get presence, read receipts and typing notifications when using # your own Matrix account as the Matrix puppet for your Hangouts account. sync_with_custom_puppets: true - + # Whether or not to bridge presence in both directions. Hangouts allows users not to broadcast # presence, but then it won't send other users' presence to the client. presence: true - + # Public website and API configs web: # Auth server config From 95750c1bc7a6da3e5b12bae4fe0c21e4db7f2899 Mon Sep 17 00:00:00 2001 From: microchipster Date: Sat, 3 Aug 2019 17:23:48 +0000 Subject: [PATCH 17/29] attempt to inject nginx config for hangouts bridge --- .../defaults/main.yml | 2 + .../tasks/init.yml | 46 +++++++++++++++++++ .../tasks/validate_config.yml | 2 +- .../nginx/conf.d/matrix-domain.conf.j2 | 7 --- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 48dedfc3..6835a3d9 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -10,6 +10,8 @@ matrix_mautrix_hangouts_base_path: "{{ matrix_base_data_path }}/mautrix-hangouts matrix_mautrix_hangouts_config_path: "{{ matrix_mautrix_hangouts_base_path }}/config" matrix_mautrix_hangouts_data_path: "{{ matrix_mautrix_hangouts_base_path }}/data" +matrix_mautrix_hangouts_public_endpoint: 'mautrix-hangouts' + matrix_mautrix_hangouts_homeserver_address: 'http://matrix-synapse:8008' matrix_mautrix_hangouts_homeserver_domain: '{{ matrix_domain }}' matrix_mautrix_hangouts_appservice_address: 'http://matrix-mautrix-hangouts:8080' diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml index 9881398d..84e33f13 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/init.yml @@ -14,3 +14,49 @@ + {{ ["/matrix-mautrix-hangouts-registration.yaml"] }} when: matrix_mautrix_hangouts_enabled|bool + +- block: + - name: Fail if matrix-nginx-proxy role already executed + fail: + msg: >- + Trying to append Mautrix Hangouts's reverse-proxying configuration to matrix-nginx-proxy, + but it's pointless since the matrix-nginx-proxy role had already executed. + To fix this, please change the order of roles in your plabook, + so that the matrix-nginx-proxy role would run after the matrix-bridge-mautrix-hangouts role. + when: matrix_nginx_proxy_role_executed|default(False)|bool + + - name: Generate Mautrix Hangouts proxying configuration for matrix-nginx-proxy + set_fact: + matrix_mautrix_hangouts_matrix_nginx_proxy_configuration: | + location {{ matrix_mautrix_hangouts_public_endpoint }} { + {% if matrix_nginx_proxy_enabled|default(False) %} + {# Use the embedded DNS resolver in Docker containers to discover the service #} + resolver 127.0.0.11 valid=5s; + set $backend "matrix-mautrix-hangouts:8080"; + proxy_pass http://$backend; + {% else %} + {# Generic configuration for use outside of our container setup #} + proxy_pass http://127.0.0.1:9007; + {% endif %} + } + - name: Register Mautrix Hangouts proxying configuration with matrix-nginx-proxy + set_fact: + matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | + {{ + matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) + + + [matrix_mautrix_hangouts_matrix_nginx_proxy_configuration] + }} + tags: + - always + when: matrix_mautrix_hangouts_enabled|bool + +- name: Warn about reverse-proxying if matrix-nginx-proxy not used + debug: + msg: >- + NOTE: You've enabled the Mautrix Hangouts bridge but are not using the matrix-nginx-proxy + reverse proxy. + Please make sure that you're proxying the `{{ matrix_mautrix_hangouts_public_endpoint }}` + URL endpoint to the matrix-mautrix-hangouts container. + You can expose the container's port using the `matrix_mautrix_hangouts_container_http_host_bind_port` variable. + when: "matrix_mautrix_hangouts_enabled|bool and matrix_nginx_proxy_enabled is not defined" diff --git a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml index 31ff3d0b..8922bef4 100644 --- a/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-hangouts/tasks/validate_config.yml @@ -6,9 +6,9 @@ You need to define a required configuration setting (`{{ item }}`). when: "vars[item] == ''" with_items: + - "matrix_mautrix_hangouts_public_endpoint" - "matrix_mautrix_hangouts_appservice_token" - "matrix_mautrix_hangouts_homeserver_token" - debug: msg: - - '`matrix_base` == {{ matrix_base }}' - '`matrix_mautrix_hangouts_homeserver_domain` == {{ matrix_mautrix_hangouts_homeserver_domain }}' diff --git a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 index 1c3e6e0f..0d234827 100644 --- a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 +++ b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-domain.conf.j2 @@ -39,13 +39,6 @@ server { ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }}; ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; - - {% if matrix_mautrix_hangouts_enabled %} - location /login { - proxy_pass http://matrix-mautrix-hangouts:8080; - proxy_set_header X-Forwarded-For $remote_addr; - } - {% endif %} location /.well-known/matrix { root {{ matrix_static_files_base_path }}; From 754c475338dfaa73b76fc89f6998222bd5013792 Mon Sep 17 00:00:00 2001 From: microchipster Date: Sat, 3 Aug 2019 17:56:29 +0000 Subject: [PATCH 18/29] matrix-hangouts/login instead of just /login --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 6835a3d9..922436bf 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -10,7 +10,7 @@ matrix_mautrix_hangouts_base_path: "{{ matrix_base_data_path }}/mautrix-hangouts matrix_mautrix_hangouts_config_path: "{{ matrix_mautrix_hangouts_base_path }}/config" matrix_mautrix_hangouts_data_path: "{{ matrix_mautrix_hangouts_base_path }}/data" -matrix_mautrix_hangouts_public_endpoint: 'mautrix-hangouts' +matrix_mautrix_hangouts_public_endpoint: 'matrix-hangouts' matrix_mautrix_hangouts_homeserver_address: 'http://matrix-synapse:8008' matrix_mautrix_hangouts_homeserver_domain: '{{ matrix_domain }}' @@ -122,7 +122,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # The prefix below is not implicitly added. This URL and all subpaths should be proxied # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. - public: "{{ matrix_domain }}/login/" + public: "mautrix-hangouts/login/" # Internal prefix in the appservice web server for the login endpoints. prefix: /login From 74d9eb1ec02587fb6c6deb3ac41ad053633e1b5b Mon Sep 17 00:00:00 2001 From: microchipster Date: Sat, 3 Aug 2019 18:27:37 +0000 Subject: [PATCH 19/29] fix incorrect nginx proxy entry for hangouts bridge --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 922436bf..d16d0c5f 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -10,7 +10,7 @@ matrix_mautrix_hangouts_base_path: "{{ matrix_base_data_path }}/mautrix-hangouts matrix_mautrix_hangouts_config_path: "{{ matrix_mautrix_hangouts_base_path }}/config" matrix_mautrix_hangouts_data_path: "{{ matrix_mautrix_hangouts_base_path }}/data" -matrix_mautrix_hangouts_public_endpoint: 'matrix-hangouts' +matrix_mautrix_hangouts_public_endpoint: '/mautrix-hangouts' matrix_mautrix_hangouts_homeserver_address: 'http://matrix-synapse:8008' matrix_mautrix_hangouts_homeserver_domain: '{{ matrix_domain }}' @@ -122,9 +122,10 @@ matrix_mautrix_hangouts_configuration_yaml: | # The prefix below is not implicitly added. This URL and all subpaths should be proxied # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. - public: "mautrix-hangouts/login/" # Internal prefix in the appservice web server for the login endpoints. - prefix: /login + public: "{{ matrix_homeserver_url }}{{ matrix_mautrix_hangouts_public_endpoint }}/" + prefix: "{{ matrix_mautrix_hangouts_public_endpoint }}/login" + # Permissions for using the bridge. # Permitted values: From 75785a0734602c14658f16c1c4ef48925458d940 Mon Sep 17 00:00:00 2001 From: microchipster Date: Sat, 3 Aug 2019 20:26:42 +0000 Subject: [PATCH 20/29] fix login url --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index d16d0c5f..3af030c5 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -123,7 +123,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # or otherwise pointed to the appservice's webserver to the path specified below (prefix). # This path should usually include a trailing slash. # Internal prefix in the appservice web server for the login endpoints. - public: "{{ matrix_homeserver_url }}{{ matrix_mautrix_hangouts_public_endpoint }}/" + public: "{{ matrix_homeserver_url }}{{ matrix_mautrix_hangouts_public_endpoint }}/login" prefix: "{{ matrix_mautrix_hangouts_public_endpoint }}/login" From 1e8d593f7a4270391d5b493bb3287e1065da14c2 Mon Sep 17 00:00:00 2001 From: microchipster Date: Sat, 3 Aug 2019 23:58:59 +0000 Subject: [PATCH 21/29] fix hangout displayname bug --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index 3af030c5..a2d5aa62 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -87,7 +87,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # {displayname} is replaced with the display name of the Hangouts user # as defined below in displayname_preference. # Keys available for displayname_preference are also available here. - displayname_template: '{displayname} (HO)' + displayname_template: '{full_name} (Hangouts)' # Available keys: # "name" (full name) # "first_name" From 122c3f1ec08e474ddc214279505ea725353968a6 Mon Sep 17 00:00:00 2001 From: microchipster Date: Tue, 6 Aug 2019 05:26:44 +0000 Subject: [PATCH 22/29] sync more chats in hangouts, switch to admin mode --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index a2d5aa62..b66dbfdd 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -102,7 +102,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # Number of chats to sync (and create portals for) on startup/login. # Maximum 20, set 0 to disable automatic syncing. - initial_chat_sync: 10 + initial_chat_sync: 20 # Whether or not the Hangouts users of logged in Matrix users should be # invited to private chats when the user sends a message from another client. invite_own_puppet_to_pm: false @@ -136,7 +136,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # domain - All users on that homeserver # mxid - Specific user permissions: - '{{ matrix_mautrix_hangouts_homeserver_domain }}': user + '{{ matrix_mautrix_hangouts_homeserver_domain }}': admin # Python logging configuration. # From 88aef08af21bd816695c2d47d600fee97c6bc7f8 Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 19 Aug 2019 22:36:16 -0700 Subject: [PATCH 23/29] Add description of mautrix hangouts bridge in readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f35081d..5443d87a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,9 @@ Using this playbook, you can get the following services configured on your serve - (optional) the [mautrix-whatsapp](https://github.com/tulir/mautrix-whatsapp) bridge for bridging your Matrix server to [Whatsapp](https://www.whatsapp.com/) -- (optional) the [mautrix-facebook](https://github.com/tulir/mautrix-facebook) bridge for bridging your Matrix server to [facebook](https://facebook.com/) +- (optional) the [mautrix-facebook](https://github.com/tulir/mautrix-facebook) bridge for bridging your Matrix server to [Facebook](https://facebook.com/) + +- (optional) the [mautrix-hangouts](https://github.com/tulir/mautrix-hangouts) bridge for bridging your Matrix server to [Google Hangouts](https://en.wikipedia.org/wiki/Google_Hangouts) - (optional) the [matrix-appservice-irc](https://github.com/TeDomum/matrix-appservice-irc) bridge for bridging your Matrix server to [IRC](https://wikipedia.org/wiki/Internet_Relay_Chat) @@ -120,6 +122,8 @@ This playbook sets up your server using the following Docker images: - [tulir/mautrix-facebook](https://hub.docker.com/r/tulir/mautrix-facebook/) - the [mautrix-facebook](https://github.com/tulir/mautrix-facebook) bridge to [Facebook](https://facebook.com/) (optional) +- [tulir/mautrix-facebook](https://hub.docker.com/r/tulir/mautrix-hangouts/) - the [mautrix-hangouts](https://github.com/tulir/mautrix-hangouts) bridge to [Google Hangouts](https://en.wikipedia.org/wiki/Google_Hangouts) (optional) + - [tedomum/matrix-appservice-irc](https://hub.docker.com/r/tedomum/matrix-appservice-irc/) - the [matrix-appservice-irc](https://github.com/TeDomum/matrix-appservice-irc) bridge to [IRC](https://wikipedia.org/wiki/Internet_Relay_Chat) (optional) - [halfshot/matrix-appservice-discord](https://hub.docker.com/r/halfshot/matrix-appservice-discord) - the [matrix-appservice-discord](https://github.com/Half-Shot/matrix-appservice-discord) bridge to [Discord](https://discordapp.com/) (optional) From 53ae84f6275e043f9e365cb9179b7e2f213fe48d Mon Sep 17 00:00:00 2001 From: Eduardo Beltrame Date: Mon, 19 Aug 2019 23:00:05 -0700 Subject: [PATCH 24/29] Add documentation on mautrix-hangouts bridge --- ...guring-playbook-bridge-mautrix-hangouts.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 docs/configuring-playbook-bridge-mautrix-hangouts.md diff --git a/docs/configuring-playbook-bridge-mautrix-hangouts.md b/docs/configuring-playbook-bridge-mautrix-hangouts.md new file mode 100644 index 00000000..8e0720ab --- /dev/null +++ b/docs/configuring-playbook-bridge-mautrix-hangouts.md @@ -0,0 +1,24 @@ +# Setting up Mautrix Hangouts (optional) + +The playbook can install and configure [mautrix-hangouts](https://github.com/tulir/mautrix-hangouts) for you. + +See the project's [documentation](https://github.com/tulir/mautrix-hangouts/wiki#usage) to learn what it does and why it might be useful to you. + +To enable the Google Hangouts bridge just use the following playbook configuration: + + +```yaml +matrix_mautrix_hangouts_enabled: true +``` + +## Usage + +Once the bot is enabled you need to start a chat with `Hangouts bridge bot` with handle `@hangoutsbot:YOUR_DOMAIN` (where `YOUR_DOMAIN` is your base domain, not the `matrix.` domain). + +Send `login` to the bridge bot to receive a link to the portal from which you can enable the bridging. Open the link sent by the bot and follow the instructions. + +Automatic login may not work. If it does not, reload the page and select the "Manual login" checkbox before starting. Manual login involves logging into your Google account normally and then manually getting the OAuth token from browser cookies with developer tools. + +Once logged in recent chats should show up as new conversations automatically. Other chats will get portals as you receive messages + +You can learn more here about authentication from the bridge's [official documentation on Authentication](https://github.com/tulir/mautrix-hangouts/wiki/Authentication). From 2efcf11ee8ddf60dd802cd1d3ca62eb54411970c Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 20 Aug 2019 09:06:14 +0300 Subject: [PATCH 25/29] Remove some whitespace --- .../templates/nginx/conf.d/matrix-synapse.conf.j2 | 2 -- 1 file changed, 2 deletions(-) diff --git a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 index 1b2e0db5..eda0929b 100644 --- a/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 +++ b/roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2 @@ -191,7 +191,6 @@ server { location / { rewrite ^/$ /_matrix/static/ last; } - } {% if matrix_nginx_proxy_proxy_matrix_federation_api_enabled %} @@ -212,7 +211,6 @@ server { ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }}; ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; - location / { {% if matrix_nginx_proxy_enabled %} From 4c9105eeeca9aa4bf0c952a814989375846c5cf8 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 20 Aug 2019 09:06:54 +0300 Subject: [PATCH 26/29] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5443d87a..413a5b41 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ This playbook sets up your server using the following Docker images: - [tulir/mautrix-facebook](https://hub.docker.com/r/tulir/mautrix-facebook/) - the [mautrix-facebook](https://github.com/tulir/mautrix-facebook) bridge to [Facebook](https://facebook.com/) (optional) -- [tulir/mautrix-facebook](https://hub.docker.com/r/tulir/mautrix-hangouts/) - the [mautrix-hangouts](https://github.com/tulir/mautrix-hangouts) bridge to [Google Hangouts](https://en.wikipedia.org/wiki/Google_Hangouts) (optional) +- [tulir/mautrix-hangouts](https://hub.docker.com/r/tulir/mautrix-hangouts/) - the [mautrix-hangouts](https://github.com/tulir/mautrix-hangouts) bridge to [Google Hangouts](https://en.wikipedia.org/wiki/Google_Hangouts) (optional) - [tedomum/matrix-appservice-irc](https://hub.docker.com/r/tedomum/matrix-appservice-irc/) - the [matrix-appservice-irc](https://github.com/TeDomum/matrix-appservice-irc) bridge to [IRC](https://wikipedia.org/wiki/Internet_Relay_Chat) (optional) From e4b67fdb6b7ad87ec9c2d72bcdb34d123270b1b6 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 20 Aug 2019 09:07:54 +0300 Subject: [PATCH 27/29] Fix typo --- group_vars/matrix_servers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index b08cdce5..7e1cc2b1 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -145,7 +145,7 @@ matrix_mautrix_hangouts_homeserver_token: "{{ matrix_synapse_macaroon_secret_key ###################################################################### # -# /matrix-bridge-mautrix-hangouts_ +# /matrix-bridge-mautrix-hangouts # ###################################################################### From 97fb71d98c744993c741013203bfb096e5363204 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Wed, 21 Aug 2019 07:12:46 +0300 Subject: [PATCH 28/29] Change privilege level --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index b66dbfdd..b23a12fa 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -136,7 +136,7 @@ matrix_mautrix_hangouts_configuration_yaml: | # domain - All users on that homeserver # mxid - Specific user permissions: - '{{ matrix_mautrix_hangouts_homeserver_domain }}': admin + '{{ matrix_mautrix_hangouts_homeserver_domain }}': user # Python logging configuration. # From 2ef8898421a1396d01c1047d4353eb96c95ef5e6 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Wed, 21 Aug 2019 07:14:31 +0300 Subject: [PATCH 29/29] Add comment --- roles/matrix-bridge-mautrix-hangouts/defaults/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml index b23a12fa..01ada495 100644 --- a/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-hangouts/defaults/main.yml @@ -3,6 +3,7 @@ matrix_mautrix_hangouts_enabled: true +# See: https://mau.dev/tulir/mautrix-hangouts/container_registry matrix_mautrix_hangouts_docker_image: "dock.mau.dev/tulir/mautrix-hangouts:latest" matrix_mautrix_hangouts_docker_image_force_pull: "{{ matrix_mautrix_hangouts_docker_image.endswith(':latest') }}"