---
# Matrix Appservice Polychat is a bridge service to multiple networks
# Project source code URL: https://github.com/polychatproject/polychat-appservice

matrix_appservice_polychat_enabled: true

matrix_appservice_polychat_scheme: https
matrix_appservice_polychat_hostname: ''
matrix_appservice_polychat_path_prefix: /appservice-polychat

matrix_appservice_polychat_container_image_self_build: false
matrix_appservice_polychat_container_image_self_build_repo: "https://github.com/polychatproject/polychat-appservice.git"
matrix_appservice_polychat_container_image_self_build_repo_version: "{{ 'master' if matrix_appservice_polychat_version == 'latest' else matrix_appservice_polychat_version }}"
matrix_appservice_polychat_container_image_self_build_repo_dockerfile_path: "Dockerfile"


matrix_appservice_polychat_docker_login_registry: "{{ matrix_appservice_polychat_registry_prefix }}"
matrix_appservice_polychat_docker_login_username: "{{ vault_matrix_appservice_polychat_docker_login_username }}" 
matrix_appservice_polychat_docker_login_password: "{{ vault_matrix_appservice_polychat_docker_login_password }}"
    

matrix_appservice_polychat_version: main
matrix_appservice_polychat_registry_prefix: ghcr.io/
matrix_appservice_polychat_docker_image: "{{ matrix_appservice_polychat_docker_image_name_prefix }}polychatproject/polychat-appservice:{{ matrix_appservice_polychat_version }}"
matrix_appservice_polychat_docker_image_name_prefix: "{{ 'localhost/' if matrix_appservice_polychat_container_image_self_build else matrix_appservice_polychat_registry_prefix }}"
matrix_appservice_polychat_docker_image_force_pull: "{{ matrix_appservice_polychat_docker_image.endswith(':latest') }}"

matrix_appservice_polychat_base_path: "{{ matrix_base_data_path }}/appservice-polychat"
matrix_appservice_polychat_config_path: "{{ matrix_appservice_polychat_base_path }}/config"
matrix_appservice_polychat_data_path: "{{ matrix_appservice_polychat_base_path }}/data"
matrix_appservice_polychat_docker_src_files_path: "{{ matrix_appservice_polychat_base_path }}/docker-src"

# If nginx-proxy is disabled, the bridge itself expects its endpoint to be on its own domain (e.g. "localhost:6789")
matrix_appservice_polychat_public_endpoint: "{{ matrix_appservice_polychat_path_prefix }}"
matrix_appservice_polychat_inbound_uri_prefix: "{{ matrix_appservice_polychat_scheme }}://{{ matrix_appservice_polychat_hostname }}{{ matrix_appservice_polychat_public_endpoint }}"

matrix_appservice_polychat_bot_name: 'webhookbot'
matrix_appservice_polychat_user_prefix: '_webhook_'

# Controls the polychat_PORT and MATRIX_PORT of the installation
matrix_appservice_polychat_matrix_port: 9999

# Controls whether the appservice-polychat container exposes its HTTP port (tcp/6789 in the container).
#
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:9999"), or empty string to not expose.
matrix_appservice_polychat_container_http_host_bind_port: '127.0.0.1:9998'

matrix_appservice_polychat_container_network: ""

matrix_appservice_polychat_container_additional_networks: "{{ matrix_appservice_polychat_container_additional_networks_auto + matrix_appservice_polychat_container_additional_networks_custom }}"
matrix_appservice_polychat_container_additional_networks_auto: []
matrix_appservice_polychat_container_additional_networks_custom: []

# matrix_appservice_polychat_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_appservice_polychat_container_labels_additional_labels`.
matrix_appservice_polychat_container_labels_traefik_enabled: true
matrix_appservice_polychat_container_labels_traefik_docker_network: "{{ matrix_appservice_polychat_container_network }}"
matrix_appservice_polychat_container_labels_traefik_entrypoints: web-secure
matrix_appservice_polychat_container_labels_traefik_tls_certResolver: default  # noqa var-naming

# Controls whether labels will be added that expose matrix-appservice-webhook's public endpoints
matrix_appservice_polychat_container_labels_public_endpoint_enabled: true
matrix_appservice_polychat_container_labels_public_endpoint_hostname: "{{ matrix_appservice_polychat_hostname }}"
matrix_appservice_polychat_container_labels_public_endpoint_prefix: "{{ matrix_appservice_polychat_path_prefix }}"
matrix_appservice_polychat_container_labels_public_endpoint_traefik_rule: "Host(`{{ matrix_appservice_polychat_container_labels_public_endpoint_hostname }}`) && PathPrefix(`{{ matrix_appservice_polychat_path_prefix }}`)"
matrix_appservice_polychat_container_labels_public_endpoint_traefik_priority: 0
matrix_appservice_polychat_container_labels_public_endpoint_traefik_entrypoints: "{{ matrix_appservice_polychat_container_labels_traefik_entrypoints }}"
matrix_appservice_polychat_container_labels_public_endpoint_traefik_tls: "{{ matrix_appservice_polychat_container_labels_public_endpoint_traefik_entrypoints != 'web' }}"
matrix_appservice_polychat_container_labels_public_endpoint_traefik_tls_certResolver: "{{ matrix_appservice_polychat_container_labels_traefik_tls_certResolver }}"  # noqa var-naming

# matrix_appservice_polychat_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_appservice_polychat_container_labels_additional_labels: |
#   my.label=1
#   another.label="here"
matrix_appservice_polychat_container_labels_additional_labels: ''

# A list of extra arguments to pass to the container
matrix_appservice_polychat_container_extra_arguments:
  - "-e API_BIND_ADDRESS=0.0.0.0"
  - "-e API_PORT=9998"
  - "-e APPSERVICE_BIND_ADDRESS=127.0.0.1"
  - "-e APPSERVICE_PORT=9999"
  - "-e DEBUG_MXID=@testuser:polychat.de"
  - "-e HOMESERVER_NAME={{ matrix_domain }}"
  - "-e HOMESERVER_URL={{ matrix_homeserver_url }}"


# List of systemd services that matrix-appservice-polychat.service depends on.
matrix_appservice_polychat_systemd_required_services_list: "{{ matrix_appservice_polychat_systemd_required_services_list_default + matrix_appservice_polychat_systemd_required_services_list_auto + matrix_appservice_polychat_systemd_required_services_list_custom }}"
matrix_appservice_polychat_systemd_required_services_list_default: ['docker.service']
matrix_appservice_polychat_systemd_required_services_list_auto: []
matrix_appservice_polychat_systemd_required_services_list_custom: []

# List of systemd services that matrix-appservice-polychat.service wants
matrix_appservice_polychat_systemd_wanted_services_list: []

matrix_appservice_polychat_homeserver_media_url: "{{ matrix_server_fqn_matrix }}"
matrix_appservice_polychat_homeserver_url: ""
matrix_appservice_polychat_homeserver_domain: "{{ matrix_domain }}"
matrix_appservice_polychat_appservice_url: 'http://matrix-appservice-polychat'

matrix_appservice_polychat_appservice_token: ''
matrix_appservice_polychat_homeserver_token: ''
matrix_appservice_polychat_id_token: ''
matrix_appservice_polychat_api_secret: ''

# Logging information (info and verbose is available) default is: info
matrix_appservice_polychat_log_level: 'info'

matrix_appservice_polychat_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}"

matrix_appservice_polychat_configuration_extension_yaml: |
  #

matrix_appservice_polychat_configuration_extension: "{{ matrix_appservice_polychat_configuration_extension_yaml | from_yaml if matrix_appservice_polychat_configuration_extension_yaml | from_yaml else {} }}"

matrix_appservice_polychat_configuration: "{{ matrix_appservice_polychat_configuration_yaml | from_yaml | combine(matrix_appservice_polychat_configuration_extension, recursive=True) }}"

matrix_appservice_polychat_registration_yaml: |
  id: "{{ matrix_appservice_polychat_id_token }}"
  hs_token: "{{ matrix_appservice_polychat_homeserver_token }}"
  as_token: "{{ matrix_appservice_polychat_appservice_token }}"
  namespaces:
    users:
      - exclusive: false
        regex: '@polychat_*'
    aliases:
      - exclusive: true
        regex: '#polychat_*'
  url: "{{ matrix_appservice_polychat_appservice_url }}:{{ matrix_appservice_polychat_matrix_port }}"
  sender_localpart: polychat
  rate_limited: false
  protocols: null

matrix_appservice_polychat_registration: "{{ matrix_appservice_polychat_registration_yaml | from_yaml }}"

