From a4178e6d7e31acb70c93e88c8aa99125bedafd0c Mon Sep 17 00:00:00 2001 From: randogoth Date: Sun, 11 Oct 2026 16:56:53 +0300 Subject: [PATCH] fix: let an author list a page they just checked --- mews/db.py | 5 ++++- mews/pages.py | 5 ++++- tests/test_service.py | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/mews/db.py b/mews/db.py index 5cb1299..e059573 100644 --- a/mews/db.py +++ b/mews/db.py @@ -223,9 +223,12 @@ def rate_limited( if rejects >= DOMAIN_REJECTS_BEFORE_SLOWDOWN else DOMAIN_COOLDOWN_MINUTES / 60 ) + # Only a real attempt at listing counts. Checking a page is the sensible + # thing to do first, and it must not lock the author out of listing it. if _count( connection, - "SELECT COUNT(*) FROM submissions WHERE domain = ? AND created_at > ?", + "SELECT COUNT(*) FROM submissions WHERE domain = ? AND created_at > ? " + "AND outcome IN ('listed', 'updated', 'rejected')", domain, _since(cooldown), ): diff --git a/mews/pages.py b/mews/pages.py index eed72a5..57d12d1 100644 --- a/mews/pages.py +++ b/mews/pages.py @@ -106,7 +106,10 @@ def report(findings_report, *, listed: bool, command: str) -> str: ) elif conforms: title = "This page conforms" - opening = "That page follows Mews Profile 0.1. There is nothing to fix." + opening = ( + "That page follows Mews Profile 0.1. Nothing was stored, and the " + "site is not in the directory: use Check and list for that." + ) else: title = "This page doesn't conform yet" opening = ( diff --git a/tests/test_service.py b/tests/test_service.py index 7f96a50..6e7a834 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -188,6 +188,22 @@ def test_rate_limits_stop_a_flood(connection): ) +def test_checking_a_page_does_not_block_listing_it(connection): + """Checking first is the sensible move; it must not cost the listing.""" + client = db.ip_hash(connection, "203.0.113.9") + db.record_submission( + connection, + url="https://a.example/", + domain="a.example", + client=client, + outcome="checked", + ) + assert ( + db.rate_limited(connection, client=client, domain="a.example", listing=True) + is None + ) + + def test_a_domain_has_to_wait_between_submissions(connection): client = db.ip_hash(connection, "203.0.113.9") db.record_submission(