vibrancy icon indicating copy to clipboard operation
vibrancy copied to clipboard

Add ability to update posts' syndication URLs if a link is returned

Open jamietanna opened this issue 4 years ago • 4 comments

Bridgy and IndieNews return a url property after syndication that is the post's syndicated URL.

We should provide some sort of middleware (for want of a better word?) that can perform this for us.

I.e. via https://brid.gy/about#response:

HTTP/1.1 201 Created
Content-Type: application/json
Location: https://twitter.com/me/status/456789

{
  "url": "https://twitter.com/me/status/456789",
  "type": "post",
  "id": "456789"
}

(The url property should be used, not the Location header)

jamietanna avatar Nov 11 '21 08:11 jamietanna

Can you explain what you think the middleware should do? If you're writing a new syndication as src/events/process-post/syndicate/[service].js you should return the URL you want to use. For the Twitter syndicator I get the tweetUrl and return that to the index.js.

barryf avatar Nov 14 '21 17:11 barryf

Sorry yeah! So what I've currently got on my site is if Bridgy/IndieNews return a $.url in the response of the post, it then performs a Micropub update to replace the syndication URL with the following request:

{
  "action": "update",
  "url": "https://www.jvt.me/mf2/2021/11/tefuk/",
  "add": {
    "syndication": ["https://twitter.com/JamieTanna/status/1459195307368108040"]
  }
}

There's some behind-the-scenes logic that removes the exisitng syndication link, with the resulting change being: https://gitlab.com/jamietanna/jvt.me/-/commit/f6114a8b40b56c7e004494d46a8f5e0d8e0dbaa1

jamietanna avatar Nov 14 '21 17:11 jamietanna

I don't think a Micropub update would be needed if you keep the URL that's returned. With the Twitter syndication I use the tweet URL that's returned is appended to the post.properties.syndication array and stored.

I think if you're using the special brid.gy syndication URL you'll want to remove that from the array before it's persisted.

barryf avatar Nov 14 '21 20:11 barryf

Even better! 👏🏽

jamietanna avatar Nov 14 '21 21:11 jamietanna