aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/tasks/discovery.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-13 21:20:40 +0100
committerDennis Fink2026-11-13 21:20:40 +0100
commita285fdf29e59c3b957247ea9241943c7202e9a28 (patch)
tree17ceeb703de23af1e67081d99a8864bbe353fb46 /webmentions_ssg/tasks/discovery.py
parent78ecd8bc227bdcbbd0e45eea025f7223252ed0da (diff)
downloadwebmentions-ssg-a285fdf29e59c3b957247ea9241943c7202e9a28.tar.gz
webmentions-ssg-a285fdf29e59c3b957247ea9241943c7202e9a28.zip
refactor(core): consolidate repeated helper logic
Centralize SQL row counts, hostname parsing, and content-type normalization so tasks, forms, and scanners share consistent implementations. Simplify periodic task registration and admin lookups with table-driven setup and Flask-SQLAlchemy's built-in 404 helper.
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/tasks/discovery.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/webmentions_ssg/tasks/discovery.py b/webmentions_ssg/tasks/discovery.py
index 107d30a..becac58 100644
--- a/webmentions_ssg/tasks/discovery.py
+++ b/webmentions_ssg/tasks/discovery.py
@@ -14,6 +14,7 @@ from flask import current_app
from ..net import (
ResponseTooLargeError,
+ content_type_of,
is_http_url,
is_temporary_status,
read_limited_body,
@@ -173,9 +174,7 @@ def discover_webmention_endpoint(client: httpx.Client, target: str) -> str | Non
if not response.is_success:
raise PermanentSenderError(f"Target returned HTTP {response.status_code}")
- media_type = (
- response.headers.get("Content-Type", "").partition(";")[0].strip().lower()
- )
+ media_type = content_type_of(response.headers)
if media_type not in {"text/html", "application/xhtml+xml"}:
return None