aaronpk / IndieNews

📰 News aggregator for IndieWeb-related posts
https://news.indieweb.org/
Other
39 stars 9 forks source link

Webmention being rejected with error about missing h-entry, but h-entry with correct u-syndication exists #49

Closed anaulin closed 4 years ago

anaulin commented 4 years ago

When I try to send a webmention from https://anaulin.org/blog/using-your-site-as-your-login-indieauth/ to https://news.indieweb.org/en, I get back the error:

{ "error": "no_link_found",
"error_description": "No h-entry or h-event was found on the page, so we were unable to find a u-syndication or u-category URL. If you have multiple top-level h-* objects, ensure that one of them has a u-url property set to the URL of the page."}

I get the same error submitting the mention manually via the form on https://news.indieweb.org/en/submit, and also doing it programmatically using the ronkyuu Python library.

However, there is a valid h-entry on the source page, and it contains a u-syndication link to news.indieweb.org. As verified by indiewebify.me (https://indiewebify.me/validate-h-entry/?url=https%3A%2F%2Fanaulin.org%2Fblog%2Fusing-your-site-as-your-login-indieauth%2F). Here is a snapshot of the source of that page: Screen Shot 2020-07-18 at 12 56 23 PM

anaulin commented 4 years ago

Digging a little deeper, and assuming that the same version of XRay is being used here as the one that is running on https://xray.p3k.io/, I see that Xray parses this post as type: feed, with one nested entry of type: entry.

This does not match the code on https://github.com/aaronpk/IndieNews/blob/master/controllers/webmention.php#L117-L120, which is checking for a top-level type value of either entry or event, which then results in the error I'm seeing.

What I don't understand (yet), is why XRay is seeing this as a feed -- is this a bug in my HTML or in XRay or...?

aaronpk commented 4 years ago

I could improve the logic in XRay here to account for this, but the simple fix that will also help other cases is to add a u-url property on your post.

What's going on here is you have an h-card at the top of the page, and the h-entry is below it. (raw parsed mf2)

The challenge then is for a consumer to figure out what this page is. If the h-entry had a u-url property that matched the URL of the page, then a consumer would be able to say "oh this is this object and I'll ignore that h-card on top. Without that, it looks like a list of objects.

What I could do in XRay is specifically look for this pattern of 1 h-card and 1 h-entry and discard the h-card since it's not likely to be a feed in that case. I'll probably do that anyway, but that's yet another step that every microformats consumer would have to do.

One common pattern is to make the timestamp of the post link to the post. If you don't want to do that, a hidden link would work too.

anaulin commented 4 years ago

Ah, thanks for explaining what was causing this. I was able to verify by adding a u-url to my post (to the timestamp, as you suggested and where I used to have it) and re-sending the mention.