From a231913ab273f427697f2d27d615b495f6e160bb Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Sun, 25 Oct 2026 20:47:14 +0100 Subject: feat(receiver): add email notifications for new webmentions Send an email after a newly received Webmention is successfully verified, with SMTP delivery configurable through Flask-Mail. Avoid notifications for resubmissions and manual reverification, and keep the persisted verification result unchanged if notification enqueueing fails. --- webmentions_ssg/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'webmentions_ssg/views.py') diff --git a/webmentions_ssg/views.py b/webmentions_ssg/views.py index b19d832..b2f7e7e 100644 --- a/webmentions_ssg/views.py +++ b/webmentions_ssg/views.py @@ -164,7 +164,7 @@ def reverify_received_webmention(identifier: uuid.UUID) -> ResponseReturnValue: db.session.commit() - verify_webmention(identifier) + verify_webmention(identifier, send_notification=False) flash(f"Webmention {webmention.uuid} queued for reverification.", "success") @@ -315,6 +315,9 @@ def endpoint() -> ResponseReturnValue: ) ).scalar_one_or_none() + # Only notify about new webmentions, not resubmissions of existing ones. + send_notification = webmention is None + if webmention is None: identifier = uuid.uuid7() @@ -326,6 +329,7 @@ def endpoint() -> ResponseReturnValue: db.session.commit() except sa_exc.IntegrityError: db.session.rollback() + send_notification = False # Another request may have inserted the same source/target pair # after our SELECT but before our COMMIT. @@ -351,7 +355,7 @@ def endpoint() -> ResponseReturnValue: db.session.commit() - verify_webmention(webmention.uuid) + verify_webmention(webmention.uuid, send_notification=send_notification) status_url = url_for("root.status", identifier=str(identifier), _external=True) -- cgit v1.3.1