aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/tasks/receiver.py
diff options
context:
space:
mode:
Diffstat (limited to 'webmentions_ssg/tasks/receiver.py')
-rw-r--r--webmentions_ssg/tasks/receiver.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/webmentions_ssg/tasks/receiver.py b/webmentions_ssg/tasks/receiver.py
index c33f517..e99eea3 100644
--- a/webmentions_ssg/tasks/receiver.py
+++ b/webmentions_ssg/tasks/receiver.py
@@ -15,6 +15,7 @@ from .. import DATABASE as db
from .. import HUEY as huey
from ..models import ReceivedWebmention
from ..url_security import AddressResolutionError, is_public_url
+from .notifications import send_webmention_notification
class VerificationError(Exception):
@@ -218,7 +219,9 @@ def source_mentions_target(source_url: str, target_url: str) -> bool:
@huey.task(retries=2, retry_delay=50)
-def verify_webmention(webmention_uuid: uuid.UUID) -> None:
+def verify_webmention(
+ webmention_uuid: uuid.UUID, send_notification: bool = True
+) -> None:
"""
Verify a received webmention and store its verification status.
@@ -226,6 +229,8 @@ def verify_webmention(webmention_uuid: uuid.UUID) -> None:
retry the task.
:param webmention_uuid: Identifier of the received webmention to verify.
+ :param send_notification: Whether to enqueue an email notification after
+ successful verification.
:raises TemporaryFetchError: If fetching the source fails temporarily.
:raises httpx.RequestError: If an HTTP request error occurs while fetching
the source.
@@ -267,3 +272,12 @@ def verify_webmention(webmention_uuid: uuid.UUID) -> None:
webmention.failure_reason = "Source does not mention target"
db.session.commit()
+
+ if send_notification:
+ try:
+ send_webmention_notification(webmention_uuid)
+ except Exception:
+ # Notification delivery must not change the persisted verification status.
+ current_app.logger.exception(
+ "Could not enqueue webmention notification for %s", webmention_uuid
+ )