aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/migrations
diff options
context:
space:
mode:
authorDennis Fink2026-11-17 19:43:04 +0100
committerDennis Fink2026-11-17 19:43:04 +0100
commit5e24e8307f650e72881f747661a2b6e52db15f2d (patch)
tree585b456b9439a17957e8633f566c0725bb9d8595 /webmentions_ssg/migrations
parent6d6d079a3a99d3d3a922a640b6925eb2adf044de (diff)
downloadwebmentions-ssg-5e24e8307f650e72881f747661a2b6e52db15f2d.tar.gz
webmentions-ssg-5e24e8307f650e72881f747661a2b6e52db15f2d.zip
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.
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/migrations/versions/ef8a9b6c2d41_received_status_history.py71
1 files changed, 71 insertions, 0 deletions
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 <me+coding@dennisfink.me>
+#
+# 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")