# SPDX-FileCopyrightText: 2022 MDAD project contributors
# SPDX-FileCopyrightText: 2024 wjbeckett
# SPDX-FileCopyrightText: 2024 - 2025 Slavi Pantaleev
#
# SPDX-License-Identifier: AGPL-3.0-or-later

---

- name: Fail if Element Call architecture is not supported
  ansible.builtin.fail:
    msg: >
      Element Call is only supported on amd64 and arm64 architectures.
      Your architecture is configured as '{{ matrix_element_call_architecture }}'.
  when: "matrix_element_call_architecture not in ['amd64', 'arm64']"

- name: Fail if required Element Call settings are not defined
  ansible.builtin.fail:
    msg: >
      You need to define a required configuration setting (`{{ item.name }}`).
  when: "item.when | bool and vars[item.name] | length == 0"
  with_items:
    - {'name': 'matrix_element_call_container_network', when: true}
    - {'name': 'matrix_element_call_hostname', when: true}
    - {'name': 'matrix_element_call_config_livekit_livekit_service_url', when: true}

# Element Call appears to hardcode all paths to `/` (e.g. `/config.json`, `/assets/...`).
# While we can properly serve the homepage and handle stripping the path prefix on our side,
# the hardcoded URLs in the Element Call are pointing people to the wrong place, which is a problem.
- name: Fail if Element Call path prefix is different than /
  ansible.builtin.fail:
    msg: >
      Element Call with a path prefix other than '/' is not supported yet.
      You have configured matrix_element_call_path_prefix to '{{ matrix_element_call_path_prefix }}'.
  when: "matrix_element_call_path_prefix != '/'"
