diff options
| author | Dennis Fink | 2026-10-25 20:47:14 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-10-25 20:47:14 +0100 |
| commit | a231913ab273f427697f2d27d615b495f6e160bb (patch) | |
| tree | b9d84e3aab3555ec88c648f790f9c31d8a4266a6 /webmentions_ssg/views.py | |
| parent | ae25061b14f8ea713ec7695848421edf84e4f0fc (diff) | |
| download | webmentions-ssg-a231913ab273f427697f2d27d615b495f6e160bb.tar.gz webmentions-ssg-a231913ab273f427697f2d27d615b495f6e160bb.zip | |
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.
Diffstat (limited to '')
| -rw-r--r-- | webmentions_ssg/views.py | 8 |
1 files changed, 6 insertions, 2 deletions
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) |
