Skip to content

Send a Webmention when a reply lands on a post that links home - #23

Open
courtneyr-dev wants to merge 1 commit into
scripting:mainfrom
courtneyr-dev:webmention-replies
Open

Send a Webmention when a reply lands on a post that links home#23
courtneyr-dev wants to merge 1 commit into
scripting:mainfrom
courtneyr-dev:webmention-replies

Conversation

@courtneyr-dev

Copy link
Copy Markdown

This closes a loop for posts that start life on a blog. My WordPress site pushes posts into rss.chat through pfefferle's plugin; people reply here; today the blog only finds out by polling. With this change the server tells the post's home page directly, using Webmention, the W3C protocol WordPress, Micro.blog, and the IndieWeb already speak.

Three pieces, all additive:

  • /newpost and /updatepost accept link — the post's canonical page somewhere else, a WordPress permalink say. The items table, the item record, and the feeds already carry link; only the write path was dropping it. Absolute http/https only, anything else quietly ignored.
  • A new server-rendered page, /item?id=N: the item as real HTML marked up as an h-entry — author, date, content, canonical guid, and for replies a link to the parent's page. It's the page a Webmention receiver fetches to verify the mention, and it doubles as the item for readers without the app. Deleted items answer 410 there. The existing ?id=N client page is untouched.
  • When a reply arrives for an item whose link points at an external page, the server discovers that page's webmention endpoint (Link header first, then a rel scan) and POSTs source and target. Edit re-sends, which is how Webmention spells "updated"; delete re-sends too, and the 410 tells the receiver the reply is gone.

Because item links are written by whoever posts, the sender refuses targets on localhost and private address ranges. Two config switches, neither required: flWebmentionNotify (on by default) turns sending off; flWebmentionAllowPrivateTargets exists for single-machine test rigs. Docs updated in api.md and config.md.

Verified end to end on a local SQLite server against a WordPress running the Webmention plugin: a reply produced a verified webmention comment on the original post, re-sending updated it in place, and a source with no target link was rejected at verification, which is the protocol working as designed.

Happy to split or reshape this however you'd prefer.

🤖 Generated with Claude Code

Posts that start life outside rss.chat -- a WordPress permalink, say --
can now carry that page in the item's link field: /newpost and
/updatepost accept link (absolute http/https only), storing it in the
column the feeds already emit. Only the write path was dropping it.

When a reply arrives for an item whose link points at an external page,
the server tells that page with a Webmention: discover the endpoint
(Link header first, then a rel scan of the page, capped at 512K), then
POST source and target. Update re-sends, which is how Webmention
spells "edited"; delete re-sends too, and the source now answers 410,
which is how receivers learn the reply is gone.

The source is a new server-rendered page, /item?id=N: the item as a
real HTML h-entry -- author, date, content, canonical guid, and for
replies a u-in-reply-to link to the parent's page. That's the page a
receiver fetches to verify the mention, and it doubles as the item for
readers without the client app. Deleted items answer 410 there.

Item links are written by whoever posts the item, so the sender
refuses targets on localhost and private ranges. Two config switches,
neither required: flWebmentionNotify (on by default) turns sending
off; flWebmentionAllowPrivateTargets exists for single-machine test
rigs and should stay off anywhere real.

Verified end to end against a WordPress running the Webmention plugin:
reply created a verified webmention comment, re-sending updated it in
place, and a source with no target link was rejected at verification.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant