4.5 KiB · text History 3d71adc
{# Queue actions for one flagged post (src/handlers/moderation.rs). Every
   form swaps the item (`#flags-<post>`) with the server's re-render, in the
   same layout (`mode`). Dismiss, moderate and delete decide the flags; a lock
   and a sanction don't. #}
{% set swap = 'hx-target="#flags-' ~ item.post_id ~ '" hx-select="unset" hx-swap="outerHTML"' %}
{% if item.resolved %}
  <span class="badge badge-success gap-1" data-resolved><i class="fas fa-check"></i>{{ item.resolved }}</span>
{% endif %}
{% if not item.resolved and not item.deleted %}
<div class="flex flex-wrap items-start gap-1">
  <form hx-post="/admin/flags/{{ item.post_id }}/dismiss" {{ swap | safe }} class="m-0">
    <input type="hidden" name="mode" value="{{ mode }}">
    <button class="btn btn-xs" type="submit" title="The post is fine; show it again if flags hid it"><i class="fas fa-check mr-1"></i>Dismiss</button>
  </form>
  <details class="dropdown">
    <summary class="btn btn-xs btn-warning list-none"><i class="fas fa-shield-halved mr-1"></i>Moderate</summary>
    <form hx-post="/admin/flags/{{ item.post_id }}/moderate" {{ swap | safe }}
          class="dropdown-content z-20 mt-1 w-72 space-y-2 rounded-box border border-base-300 bg-base-100 p-3 shadow-lg">
      <input type="hidden" name="mode" value="{{ mode }}">
      <textarea name="note" rows="3" required class="textarea textarea-bordered textarea-xs w-full" placeholder="Staff note that replaces the post"></textarea>
      <label class="flex items-center gap-2 text-xs"><input type="checkbox" name="hide_original" value="1" class="checkbox checkbox-xs" checked> Hide the original from non-staff</label>
      <div class="flex justify-end"><button class="btn btn-warning btn-xs" type="submit">Replace with note</button></div>
    </form>
  </details>
  <form hx-post="/admin/flags/{{ item.post_id }}/delete" {{ swap | safe }} class="m-0"
        hx-confirm="Delete this post? Its flags are marked upheld.">
    <input type="hidden" name="mode" value="{{ mode }}">
    <button class="btn btn-xs btn-error" type="submit"><i class="fas fa-trash mr-1"></i>Delete</button>
  </form>
  {% if item.topic_locked %}
  <span class="badge badge-ghost gap-1 py-2.5"><i class="fas fa-lock"></i>Topic locked</span>
  {% else %}
  <details class="dropdown">
    <summary class="btn btn-xs list-none"><i class="fas fa-lock mr-1"></i>Lock topic</summary>
    <form hx-post="/admin/flags/{{ item.post_id }}/lock" {{ swap | safe }}
          class="dropdown-content z-20 mt-1 w-64 space-y-2 rounded-box border border-base-300 bg-base-100 p-3 shadow-lg">
      <input type="hidden" name="mode" value="{{ mode }}">
      <input name="reason" class="input input-bordered input-xs w-full" placeholder="Reason (shown to everyone)">
      <div class="flex justify-end"><button class="btn btn-xs btn-warning" type="submit">Lock</button></div>
    </form>
  </details>
  {% endif %}
</div>
{% endif %}
{% if not item.author_staff %}
<div class="flex flex-wrap items-center gap-1 mt-1 text-xs" data-author-actions>
  <span class="opacity-60">Author <a href="/admin/users/{{ item.author_id }}" class="link link-hover font-medium">{{ item.author }}</a>:</span>
  {% if item.author_silenced %}
    <span class="badge badge-warning badge-sm">{{ item.author_silenced }}</span>
    <form hx-post="/admin/users/{{ item.author_id }}/unsilence" {{ swap | safe }} class="m-0">
      <input type="hidden" name="mode" value="{{ mode }}"><input type="hidden" name="post" value="{{ item.post_id }}">
      <button class="btn btn-ghost btn-xs" type="submit">Lift silence</button>
    </form>
  {% else %}
    {% with action = "silence", label = "Silence", target = item.author_id, post_id = item.post_id %}{% include "admin/_sanction_form.html" %}{% endwith %}
  {% endif %}
  {% if item.author_suspended %}
    <span class="badge badge-error badge-sm">{{ item.author_suspended }}</span>
    <form hx-post="/admin/users/{{ item.author_id }}/unsuspend" {{ swap | safe }} class="m-0">
      <input type="hidden" name="mode" value="{{ mode }}"><input type="hidden" name="post" value="{{ item.post_id }}">
      <button class="btn btn-ghost btn-xs" type="submit">Lift suspension</button>
    </form>
  {% else %}
    {% with action = "suspend", label = "Suspend", target = item.author_id, post_id = item.post_id %}{% include "admin/_sanction_form.html" %}{% endwith %}
  {% endif %}
  {% with target = item.author_id, ignored = item.author_flags_ignored, name = item.author, swap_target = "#flags-" ~ item.post_id, post_id = item.post_id %}{% include "admin/_shadow_form.html" %}{% endwith %}
</div>
{% endif %}