Skip to content
Permalink
Browse files

Emit redirection warning for webmention targets

  • Loading branch information...
fluffy-critter committed Aug 21, 2019
1 parent da5900e commit a9451f72abd85986cf075617e615c2c29ec7ecf8
Showing with 19 additions and 8 deletions.
  1. +10 −5 pushl/__init__.py
  2. +2 −1 pushl/entries.py
  3. +6 −0 pushl/webmentions.py
  4. +1 −2 setup.cfg
@@ -117,15 +117,17 @@ def __init__(self, session, args):
pending = []

if updated:
LOGGER.info("Processing entry: %s send_mentions=%s", url, send_mentions)
LOGGER.info("Processing entry: %s send_mentions=%s",
url, send_mentions)
if send_mentions:
# get the webmention targets
links = entry.get_targets(self)
if previous:
# Only bother with links that changed from the last time
LOGGER.debug("targets before: %s", links)
invert = previous.get_targets(self)
LOGGER.debug("%s: excluding previously-checked targets %s", url, invert)
LOGGER.debug(
"%s: excluding previously-checked targets %s", url, invert)
links = links ^ invert

if links:
@@ -171,15 +173,18 @@ def __init__(self, session, args):
LOGGER.debug("++DONE: webmentions.get_target %s", resolved)

if target:
LOGGER.debug("++WAIT: Sending webmention %s -> %s", entry.url, href)
LOGGER.debug("++WAIT: Sending webmention %s -> %s",
entry.url, href)
await target.send(self, entry)
LOGGER.debug("++DONE: Sending webmention %s -> %s", entry.url, href)
LOGGER.debug("++DONE: Sending webmention %s -> %s",
entry.url, href)

async def send_websub(self, url, hub):
""" send a websub notification """

if (url, hub) in self._processed_websub:
LOGGER.debug("Skipping already processed websub %s -> %s", url, hub)
LOGGER.debug(
"Skipping already processed websub %s -> %s", url, hub)
return
self._processed_websub.add((url, hub))

@@ -45,7 +45,8 @@ def __init__(self, request):
and link.attrs['type'] in ('application/rss.xml',
'application/atom+xml')]

self.hubs = [link.attrs['href'] for link in soup.find_all('link', rel='hub')]
self.hubs = [link.attrs['href']
for link in soup.find_all('link', rel='hub')]
if 'hub' in request.links:
self.hubs.append(request.links['hub']['url'])

@@ -163,6 +163,12 @@ def join(url):
LOGGER.exception("Ping %s: got %s: %s",
self.resolved, err.__class__.__name__, err)

if self.resolved != self.href:
# pylint:disable=line-too-long
LOGGER.warning(
"Note: For greatest compatibility, URL %s (referenced from %s) should be updated to %s",
self.href, entry.url, self.resolved)


@async_lru.alru_cache(maxsize=1000)
async def get_target(config, url, href):
@@ -2,6 +2,5 @@
license_file = LICENSE

[flake8]
max-line-length = 100
ignore = E722, W503, W504
ignore = E722, W503, W504, E501
exclude = .git, build, __pycache__

0 comments on commit a9451f7

Please sign in to comment.
You can’t perform that action at this time.