{% extends "app.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}

{% load i18n %}
{% load static %}

{% block page_js %}
  <script type="text/javascript" src="{% static 'matrixsynapse/matrixsynapse.js' %}"
          defer></script>
{% endblock %}

{% block status %}
  {{ block.super }}

  <h3>{% trans "Status" %}</h3>

  <p>
    {% blocktrans trimmed %}
      The Matrix server domain is set to <em>{{ domain_name }}</em>. User IDs
      will look like <em>@username:{{ domain_name }}</em>. Changing the domain
      name requires uninstalling and reinstalling the app which will wipe app's
      data.
    {% endblocktrans %}
  </p>
  <p>
    {% blocktrans trimmed %}
      New users can be registered from any client if public registration is
      enabled.
    {% endblocktrans %}
  </p>
  {% if config.public_registration and config.registration_verification == 'token' and registration_tokens %}
    <p>
      {% blocktrans trimmed %}
        New users must use one of the following tokens for verification during
        account registration:
      {% endblocktrans %}
    </p>
    <div class="table-responsive table-registration-tokens">
      <table class="table">
        <thead>
          <tr>
            <th>{% trans "Registration Token" %}</th>
            <th>{% trans "Uses Allowed" %}</th>
            <th>{% trans "Pending Registrations" %}</th>
            <th>{% trans "Completed Registrations" %}</th>
            <th>{% trans "Expiry Time" %}</th>
          </tr>
        </thead>
        <tbody>
          {% for token in registration_tokens %}
            <tr>
              <td>{{ token.token }}</td>
              <td>
                {% if token.uses_allowed is None %}
                  {% trans "Unlimited" %}
                {% else %}
                  {{ token.uses_allowed }}
                {% endif %}
              </td>
              <td>{{ token.pending }}</td>
              <td>{{ token.completed }}</td>
              <td>
                {% if token.expiry_time %}
                  {{ token.expiry_time|date:"DATETIME_FORMAT" }}
                {% else %}
                  {% trans "None" %}
                {% endif %}
              </td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  {% endif %}

  <h3>{% trans "Federation" %}</h3>

  <p>
    {% blocktrans trimmed with tester_url="https://federationtester.matrix.org/" %}
      Matrix Synapse is configured to work with other Matrix servers on the
      internet. This allows {{ box_name }} users to participate in rooms that
      are hosted elsewhere and Matrix users on other servers to participate
      in rooms hosted here. If you face problems with federation, try the
      <a href="{{ tester_url }}#{{ domain_name }}">
      federation tester tool</a>.
    {% endblocktrans %}
  </p>

  {% if certificate_status != "valid" %}
    <div class="alert alert-warning d-flex align-items-center" role="alert">
      <div class="me-2">
        <span class="fa fa-exclamation-triangle" aria-hidden="true"></span>
        <span class="visually-hidden">{% trans "Caution:" %}</span>
      </div>
      <div>
        {% url 'letsencrypt:index' as letsencrypt_url %}
        {% blocktrans trimmed %}
          The configured domain name is using a self-signed certificate.
          Federation with other Matrix Synapse instances requires a valid TLS
          certificate. Please go to <a href="{{ letsencrypt_url }}">Let's
          Encrypt</a> to obtain one.
        {% endblocktrans %}
      </div>
    </div>
  {% endif %}
{% endblock %}
