From 63af533d98aac82b6d4f069b217d3e837285508d Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Tue, 17 Nov 2026 22:10:40 +0100 Subject: feat(receiver): explain received Webmention failures Map known verification failures to human-readable explanations and show suggested next steps only for receiver-controlled problems while retaining raw reasons. Return a specific validation error when targets are outside `ALLOWED_TARGET_HOSTNAMES` and reuse the guidance for status history. --- .../templates/includes/received_failure.html | 22 ++++++++++++++++++ webmentions_ssg/templates/received_detail.html | 27 +++++++++++++--------- 2 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 webmentions_ssg/templates/includes/received_failure.html (limited to 'webmentions_ssg/templates') diff --git a/webmentions_ssg/templates/includes/received_failure.html b/webmentions_ssg/templates/includes/received_failure.html new file mode 100644 index 0000000..65ed7a3 --- /dev/null +++ b/webmentions_ssg/templates/includes/received_failure.html @@ -0,0 +1,22 @@ + + +{% macro render_failure(reason) %} + {% set guidance = reason | received_failure_guidance %} + {% if guidance %} +
{{ guidance.explanation }}
+ {% if guidance.next_step %} +
Suggested next step: {{ guidance.next_step }}
+ {% endif %} +
+ Technical reason +
{{ reason }}
+
+ {% else %} +
{{ reason }}
+
Check the application logs for details before reverifying.
+ {% endif %} +{% endmacro %} diff --git a/webmentions_ssg/templates/received_detail.html b/webmentions_ssg/templates/received_detail.html index 091e2e4..32d3e05 100644 --- a/webmentions_ssg/templates/received_detail.html +++ b/webmentions_ssg/templates/received_detail.html @@ -5,6 +5,7 @@ SPDX-License-Identifier: BSD-3-Clause --> {% extends "base.html" %} +{% from "includes/received_failure.html" import render_failure %} {% set status_presentation = { "received": { "badge": "text-bg-info", @@ -78,7 +79,7 @@ SPDX-License-Identifier: BSD-3-Clause
Failure reason
{% if webmention.failure_reason %} -
{{ webmention.failure_reason }}
+ {{ render_failure(webmention.failure_reason) }} {% else %} None {% endif %} @@ -121,17 +122,21 @@ SPDX-License-Identifier: BSD-3-Clause
    {% for event in history %} {% set event_style = status_presentation.get(event.status, {"badge": "text-bg-secondary", "label": "Unknown"}) %} -
  1. -
    - {{ event_style.label }} - {{ event.action }} - +
  2. +
    +
    + {{ event_style.label }} + {{ event.action }} + +
    +
    Recovery attempts: {{ event.recovery_attempts }}
    + {% if event.failure_reason %} +
    {{ render_failure(event.failure_reason) }}
    + {% endif %}
    -
    Recovery attempts: {{ event.recovery_attempts }}
    - {% if event.failure_reason %} -
    {{ event.failure_reason }}
    - {% endif %}
  3. {% endfor %}
-- cgit v1.3.1