diff --git a/README.md b/README.md index d7d02c8..e3b986e 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,4 @@ Retrieves a JSON array with relevant webmentions stored for that domain. The tok ## TODOs - `published` date is not well-formatted and blindly taken over from feed - +- [brid.gy](https://brid.gy/) does not send webmentions if no target found, although I'd like these to appear in the [brainbaking.com/notes](https://brainbaking.com/notes) somehow, being syndicated from my Mastodon feed. diff --git a/src/webmention/receive.js b/src/webmention/receive.js index 9bd9a57..95654cd 100644 --- a/src/webmention/receive.js +++ b/src/webmention/receive.js @@ -82,10 +82,11 @@ function parseBodyAsIndiewebSite(source, target, hEntry) { const picture = hEntry.properties?.author?.[0]?.properties?.photo?.[0] const summary = hEntry.properties?.summary?.[0] const contentEntry = hEntry.properties?.content?.[0]?.value + const bridgyTwitterContent = hEntry.properties?.["bridgy-twitter-content"]?.[0] const publishedDate = hEntry.properties?.published?.[0] const uid = hEntry.properties?.uid?.[0] const url = hEntry.properties?.url?.[0] - const type = hEntry.properties?.["like-of"]?.length ? "like" : "mention" + const type = hEntry.properties?.["like-of"]?.length ? "like" : (hEntry.properties?.["bookmark-of"]?.length ? "bookmark" : "mention" ) return { author: { @@ -93,7 +94,7 @@ function parseBodyAsIndiewebSite(source, target, hEntry) { picture: picture.value ? picture.value : picture }, name: name, - content: summary ? shorten(summary) : shorten(contentEntry), + content: bridgyTwitterContent ? shorten(bridgyTwitterContent) : (summary ? shorten(summary) : shorten(contentEntry)), published: publishedDate ? publishedDate : publishedNow(), type, // Mastodon uids start with "tag:server", but we do want indieweb uids from other sources diff --git a/test/__mocks__/valid-bridgy-twitter-source.html b/test/__mocks__/valid-bridgy-twitter-source.html new file mode 100644 index 0000000..0946ff3 --- /dev/null +++ b/test/__mocks__/valid-bridgy-twitter-source.html @@ -0,0 +1,14 @@ +The IndieWeb Mixed Bag - Thoughts about the (d)evolution of blog interactions · Jamie Tanna | Software Engineer

The IndieWeb Mixed Bag - Thoughts about the (d)evolution of blog interactions

Recommended read: +The IndieWeb Mixed Bag - Thoughts about the (d)evolution of blog interactions +https://brainbaking.com/post/2021/03/the-indieweb-mixed-bag/

This post was filed under bookmarks.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

+ +

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.

+ diff --git a/test/webmention/receive-process.test.js b/test/webmention/receive-process.test.js index 1e49ca7..48380d5 100644 --- a/test/webmention/receive-process.test.js +++ b/test/webmention/receive-process.test.js @@ -26,6 +26,19 @@ describe("receive webmention process tests happy path", () => { return `${dumpdir}/` + md5(`source=${body.source},target=${body.target}`) } + test("receive a webmention bookmark via twitter", async () => { + const body = { + source: "https://brainbaking.com/valid-bridgy-twitter-source.html", + target: "https://brainbaking.com/post/2021/03/the-indieweb-mixed-bag" + } + await receive(body) + + const result = await fsp.readFile(`${asFilename(body)}.json`, 'utf-8') + const data = JSON.parse(result) + expect(data.type).toEqual("bookmark"); + expect(data.content).toContain("Recommended read:") + }) + test("receive a brid.gy webmention like", async () => { const body = { source: "https://brainbaking.com/valid-bridgy-like.html",