From eb191a61ec0f763e20d6e5dd8ed69102e0d1a3e8 Mon Sep 17 00:00:00 2001 From: Barry Frost Date: Sun, 3 Sep 2023 10:43:29 +0100 Subject: [PATCH] Use absolute URLs to send webmention --- src/events/process-post/index.js | 5 +++-- src/events/send-webmention/index.js | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/events/process-post/index.js b/src/events/process-post/index.js index 8f03721..0d4da62 100644 --- a/src/events/process-post/index.js +++ b/src/events/process-post/index.js @@ -23,11 +23,12 @@ exports.handler = async function subscribe (event) { } // fire webmentions asynchronously - const links = await findLinks(url) + const absoluteUrl = new URL(url, process.env.ROOT_URL).href + const links = await findLinks(absoluteUrl) for (const link of links) { await arc.events.publish({ name: 'send-webmention', - payload: { url, link } + payload: { source: absoluteUrl, target: link } }) } diff --git a/src/events/send-webmention/index.js b/src/events/send-webmention/index.js index f30a5ec..cfaf9e5 100644 --- a/src/events/send-webmention/index.js +++ b/src/events/send-webmention/index.js @@ -22,6 +22,5 @@ async function sendWebmention (source, target) { exports.handler = async function subscribe (event) { const body = JSON.parse(event.Records[0].Sns.Message) - const url = new URL(body.url, process.env.ROOT_URL).href - await sendWebmention(url, body.link) + await sendWebmention(body.source, body.target) }