fix: don't send webmentions to this site or WEBMENTION_SKIP_HOSTS (v2.18.3)
Links to the site itself, and to self-hosted apps like Gitea, timed out from inside the container and sat in the admin Log. They are now skipped when queueing; already queued or failed ones are dropped at worker start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
52ecf0f713
commit
b9e5321df2
10 files changed
+223
-5
No files matched your search
@@ -205,6 +205,40 @@ class WebmentionWorker(threading.Thread):
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to cleanup orphaned items: {e}")
|
||||
|
||||
self._drop_skipped_targets()
|
||||
|
||||
def _skipped_hosts(self) -> set:
|
||||
from starpunk.webmention_sender import skipped_hosts
|
||||
return skipped_hosts(self.app.config) if self.app is not None else set()
|
||||
|
||||
def _drop_skipped_targets(self):
|
||||
"""
|
||||
Stop sending to this site and WEBMENTION_SKIP_HOSTS (v2.18.3)
|
||||
|
||||
Queued or failed sends to those hosts are set to 'no_endpoint' (nothing
|
||||
to send to), so they leave the retry queue and the admin Log.
|
||||
"""
|
||||
from starpunk.webmention_sender import SKIPPED_NOTE, is_skipped
|
||||
|
||||
hosts = self._skipped_hosts()
|
||||
if not hosts:
|
||||
return
|
||||
try:
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
rows = conn.execute(
|
||||
"SELECT id, target_url FROM webmention_queue WHERE status IN ('pending', 'failed')"
|
||||
).fetchall()
|
||||
ids = [(SKIPPED_NOTE, i) for i, url in rows if is_skipped(url, hosts)]
|
||||
if ids:
|
||||
conn.executemany(
|
||||
"UPDATE webmention_queue SET status = 'no_endpoint', last_error = ? WHERE id = ?",
|
||||
ids)
|
||||
conn.commit()
|
||||
logger.info(f"Dropped {len(ids)} queued webmention(s) to skipped hosts")
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to drop skipped webmention targets: {e}")
|
||||
|
||||
def _process_pending_validations(self) -> int:
|
||||
"""
|
||||
Process pending incoming webmentions
|
||||
@@ -583,6 +617,15 @@ class WebmentionWorker(threading.Thread):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
from starpunk.webmention_sender import SKIPPED_NOTE, is_skipped
|
||||
if is_skipped(target_url, self._skipped_hosts()):
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
conn.execute("UPDATE webmention_queue SET status = 'no_endpoint', last_error = ? WHERE id = ?",
|
||||
(SKIPPED_NOTE, queue_id))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return
|
||||
|
||||
try:
|
||||
# Discover endpoint if not cached
|
||||
endpoint = cached_endpoint
|
||||
|
||||
Reference in new issue
Block a user