diff options
| author | Dennis Fink | 2026-11-17 19:43:04 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-17 19:43:04 +0100 |
| commit | 5e24e8307f650e72881f747661a2b6e52db15f2d (patch) | |
| tree | 585b456b9439a17957e8633f566c0725bb9d8595 /webmentions_ssg/views/endpoint.py | |
| parent | 6d6d079a3a99d3d3a922a640b6925eb2adf044de (diff) | |
| download | webmentions-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/views/endpoint.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/webmentions_ssg/views/endpoint.py b/webmentions_ssg/views/endpoint.py index 322e0f0..36c4693 100644 --- a/webmentions_ssg/views/endpoint.py +++ b/webmentions_ssg/views/endpoint.py @@ -17,7 +17,11 @@ from flask.typing import ResponseReturnValue from ..db_helpers import rows_affected from ..extensions import csrf, db, limiter from ..forms.endpoint import WebmentionSubmissionForm -from ..models.received import ReceivedWebmention +from ..models.received import ( + ReceivedWebmention, + ReceivedWebmentionStatus, + ReceivedWebmentionStatusEvent, +) from ..models.utils import source_target_digest from ..moderation_policy import rejection_reason from ..tasks.verification import verify_webmention @@ -66,6 +70,14 @@ def try_insert_received_webmention( """ webmention = ReceivedWebmention(uuid=uuid.uuid7(), source=source, target=target) db.session.add(webmention) + webmention.status_events.append( + ReceivedWebmentionStatusEvent( + webmention_uuid=webmention.uuid, + status=ReceivedWebmentionStatus.RECEIVED, + action="Received submission", + occurred_at=webmention.created_at, + ) + ) try: db.session.commit() @@ -98,8 +110,20 @@ def reopen_if_cooldown_elapsed(webmention: ReceivedWebmention) -> bool: .values(ReceivedWebmention.reopen_verification_values(at=now)) .execution_options(synchronize_session=False) ) + if rows_affected(result) != 1: + db.session.rollback() + return False + + db.session.add( + ReceivedWebmentionStatusEvent( + webmention_uuid=webmention.uuid, + status=ReceivedWebmentionStatus.RECEIVED, + action="Resubmitted after cooldown", + occurred_at=now, + ) + ) db.session.commit() - return rows_affected(result) == 1 + return True def record_submission(source: str, target: str) -> tuple[uuid.UUID, bool] | None: |
