Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jamietanna opened this issue Nov 11, 2021 · 4 comments
Open

Comments

@jamietanna
Copy link
Contributor

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)

@barryf
Copy link
Owner

barryf commented Nov 14, 2021

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.

@jamietanna
Copy link
Contributor Author

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

@barryf
Copy link
Owner

barryf commented Nov 14, 2021

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.

@jamietanna
Copy link
Contributor Author

Even better! 👏🏽

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

No branches or pull requests

2 participants