diff options
Diffstat (limited to 'webmentions_ssg/tasks')
| -rw-r--r-- | webmentions_ssg/tasks/consumer.py | 4 | ||||
| -rw-r--r-- | webmentions_ssg/tasks/notifications.py | 2 | ||||
| -rw-r--r-- | webmentions_ssg/tasks/receiver.py | 10 | ||||
| -rw-r--r-- | webmentions_ssg/tasks/scanner.py | 15 | ||||
| -rw-r--r-- | webmentions_ssg/tasks/sender.py | 8 |
5 files changed, 14 insertions, 25 deletions
diff --git a/webmentions_ssg/tasks/consumer.py b/webmentions_ssg/tasks/consumer.py index d71f2fa..3ba2638 100644 --- a/webmentions_ssg/tasks/consumer.py +++ b/webmentions_ssg/tasks/consumer.py @@ -21,9 +21,7 @@ def create_consumer() -> Huey: from . import notifications, receiver, scanner, sender # noqa: F401 - schedule = crontab( - *app.config["WEBMENTIONS_SSG_SCANNER_SCHEDULE"].split(), strict=True - ) + schedule = crontab(*app.config["SCANNER_SCHEDULE"].split(), strict=True) HUEY.periodic_task(schedule)(scanner.scan_sources) return HUEY.huey diff --git a/webmentions_ssg/tasks/notifications.py b/webmentions_ssg/tasks/notifications.py index 473216b..04c968a 100644 --- a/webmentions_ssg/tasks/notifications.py +++ b/webmentions_ssg/tasks/notifications.py @@ -16,7 +16,7 @@ from ..models import ReceivedWebmention @huey.task(retries=2, retry_delay=60) def send_webmention_notification(webmention_uuid: uuid.UUID) -> None: """Send an email when a received webmention has been verified.""" - recipient = current_app.config.get("WEBMENTIONS_SSG_NOTIFICATION_EMAIL") + recipient = current_app.config.get("NOTIFICATION_EMAIL") if not recipient: return diff --git a/webmentions_ssg/tasks/receiver.py b/webmentions_ssg/tasks/receiver.py index e99eea3..8c9c05a 100644 --- a/webmentions_ssg/tasks/receiver.py +++ b/webmentions_ssg/tasks/receiver.py @@ -137,11 +137,9 @@ def fetch_source(source_url: str) -> tuple[httpx.Response, bytes]: "Accept": "text/html, application/xhtml+xml;q=0.9, text/plain;q=0.8", "User-Agent": f"{APP_NAME}/{VERSION} ReceivedWebmention", }, - timeout=httpx.Timeout( - current_app.config.get("WEBMENTIONS_SSG_REQUEST_TIMEOUT", 5.0) - ), + timeout=httpx.Timeout(current_app.config.get("REQUEST_TIMEOUT", 5.0)), follow_redirects=True, - max_redirects=current_app.config.get("WEBMENTIONS_SSG_MAX_REDIRECTS", 20), + max_redirects=current_app.config.get("MAX_REDIRECTS", 20), trust_env=False, event_hooks={"request": [ensure_public_request]}, ) as client, @@ -158,9 +156,7 @@ def fetch_source(source_url: str) -> tuple[httpx.Response, bytes]: else: raise VerificationError(f"Source returned HTTP {status}") - max_source_bytes = current_app.config.get( - "WEBMENTIONS_SSG_MAX_SOURCE_BYTES", 1_000_000 - ) + max_source_bytes = current_app.config.get("MAX_SOURCE_BYTES", 1_000_000) if (content_length := response.headers.get("Content-Length")) is not None: try: diff --git a/webmentions_ssg/tasks/scanner.py b/webmentions_ssg/tasks/scanner.py index 17898ba..1980abb 100644 --- a/webmentions_ssg/tasks/scanner.py +++ b/webmentions_ssg/tasks/scanner.py @@ -79,7 +79,7 @@ def canonical_url( if base_url is None: raise SourceScanError( "Document contains a relative canonical URL, but " - "WEBMENTIONS_SSG_SOURCE_BASE_URL is not configured" + "SOURCE_BASE_URL is not configured" ) resolved = urljoin(source_url_for_path(relative_path, base_url), href) @@ -292,8 +292,7 @@ def scan_source_file( if source_url is None: if base_url is None: raise SourceScanError( - "Document has no canonical URL and " - "WEBMENTIONS_SSG_SOURCE_BASE_URL is not configured" + "Document has no canonical URL and SOURCE_BASE_URL is not configured" ) source_url = source_url_for_path(relative_path, base_url) @@ -410,7 +409,7 @@ def scan_sources() -> None: :raises RuntimeError: If the configured source directory or base URL is invalid. """ - directory = current_app.config.get("WEBMENTIONS_SSG_SOURCE_DIRECTORY") + directory = current_app.config.get("SOURCE_DIRECTORY") if directory is None: return @@ -420,18 +419,16 @@ def scan_sources() -> None: if not root.is_dir(): raise RuntimeError(f"Source directory is not a directory: {root}") - base_url = current_app.config.get("WEBMENTIONS_SSG_SOURCE_BASE_URL") + base_url = current_app.config.get("SOURCE_BASE_URL") if base_url is not None: if not is_http_url(base_url): - raise RuntimeError( - "WEBMENTIONS_SSG_SOURCE_BASE_URL must be an absolute HTTP or HTTPS URL" - ) + raise RuntimeError("SOURCE_BASE_URL must be an absolute HTTP or HTTPS URL") base_url = f"{base_url.rstrip('/')}/" ignored_hostnames = tuple( pattern.lower().rstrip(".") - for pattern in current_app.config.get("WEBMENTIONS_SSG_IGNORED_HOSTNAMES", ()) + for pattern in current_app.config.get("IGNORED_HOSTNAMES", ()) ) sources_by_path = { diff --git a/webmentions_ssg/tasks/sender.py b/webmentions_ssg/tasks/sender.py index 1d22ad9..3b79448 100644 --- a/webmentions_ssg/tasks/sender.py +++ b/webmentions_ssg/tasks/sender.py @@ -175,7 +175,7 @@ def read_target_body(response: httpx.Response) -> bytes: :raises PermanentSenderError: If the document exceeds the configured maximum size. """ - max_bytes = current_app.config.get("WEBMENTIONS_SSG_MAX_TARGET_BYTES", 1_000_000) + max_bytes = current_app.config.get("MAX_TARGET_BYTES", 1_000_000) if (content_length := response.headers.get("Content-Length")) is not None: try: @@ -324,11 +324,9 @@ def send_webmention(webmention_uuid: uuid.UUID) -> None: try: with httpx.Client( headers={"User-Agent": (f"{APP_NAME}/{VERSION} SentWebmention")}, - timeout=httpx.Timeout( - current_app.config.get("WEBMENTIONS_SSG_REQUEST_TIMEOUT", 5.0) - ), + timeout=httpx.Timeout(current_app.config.get("REQUEST_TIMEOUT", 5.0)), follow_redirects=True, - max_redirects=current_app.config.get("WEBMENTIONS_SSG_MAX_REDIRECTS", 20), + max_redirects=current_app.config.get("MAX_REDIRECTS", 20), trust_env=False, event_hooks={"request": [ensure_public_request]}, ) as client: |
