From 5e24e8307f650e72881f747661a2b6e52db15f2d Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Tue, 17 Nov 2026 19:43:04 +0100 Subject: feat(receiver): add Webmention detail and status history Add an authenticated detail view with full failure information, timestamps, actions, public status links, and recorded lifecycle transitions. Persist verification and resubmission events, backfill existing rows during migration, and clean up history when received Webmentions are deleted. --- .../ef8a9b6c2d41_received_status_history.py | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 webmentions_ssg/migrations/versions/ef8a9b6c2d41_received_status_history.py (limited to 'webmentions_ssg/migrations') diff --git a/webmentions_ssg/migrations/versions/ef8a9b6c2d41_received_status_history.py b/webmentions_ssg/migrations/versions/ef8a9b6c2d41_received_status_history.py new file mode 100644 index 0000000..db63011 --- /dev/null +++ b/webmentions_ssg/migrations/versions/ef8a9b6c2d41_received_status_history.py @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2026 Dennis Fink +# +# SPDX-License-Identifier: BSD-3-Clause + +"""Record received Webmention lifecycle transitions. + +Revision ID: ef8a9b6c2d41 +Revises: a4f91c2e08d7 +""" + +import sqlalchemy as sa +from alembic import op + +revision = "ef8a9b6c2d41" +down_revision = "a4f91c2e08d7" +branch_labels = None +depends_on = None + + +def upgrade(): + op.create_table( + "received_webmention_status_events", + sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True), + sa.Column("webmention_uuid", sa.Uuid(), nullable=False), + sa.Column( + "status", + sa.Enum( + "received", + "verifying", + "verified", + "failed", + "source_removed", + name="received_webmention_status", + native_enum=False, + ), + nullable=False, + ), + sa.Column("action", sa.String(length=80), nullable=False), + sa.Column("failure_reason", sa.Text(), nullable=True), + sa.Column("recovery_attempts", sa.Integer(), nullable=False), + sa.Column("occurred_at", sa.DateTime(timezone=True), nullable=False), + sa.ForeignKeyConstraint( + ["webmention_uuid"], + ["received_webmentions.uuid"], + ondelete="CASCADE", + ), + ) + op.create_index( + "ix_received_webmention_status_events_webmention_id", + "received_webmention_status_events", + ["webmention_uuid", "id"], + ) + + # Existing rows have no saved transitions; record just the last known state. + op.execute( + sa.text( + """INSERT INTO received_webmention_status_events + (webmention_uuid, status, action, failure_reason, recovery_attempts, occurred_at) + SELECT uuid, status, 'Existing status at upgrade', + failure_reason, recovery_attempts, updated_at + FROM received_webmentions""" + ) + ) + + +def downgrade(): + op.drop_index( + "ix_received_webmention_status_events_webmention_id", + table_name="received_webmention_status_events", + ) + op.drop_table("received_webmention_status_events") -- cgit v1.3.1