From 44354dac5e61dd25104b093d5679d13db3d50f6d Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 7 Mar 2025 14:18:09 -0500 Subject: [PATCH] fix: handling of `href` in remote object attachments, #13169 --- src/posts/attachments.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/posts/attachments.js b/src/posts/attachments.js index 99aece3010..b9dd569d70 100644 --- a/src/posts/attachments.js +++ b/src/posts/attachments.js @@ -39,11 +39,15 @@ Attachments.update = async (pid, attachments) => { hash: [], }; const hashes = []; - attachments.filter(Boolean).forEach(({ _type, mediaType, url, name, width, height }) => { - if (!url) { // only required property + attachments.filter(Boolean).forEach(({ _type, mediaType, href, url, name, width, height }) => { + if (!url && !href) { // one or the other are required return; } + if (!url && href) { + url = href; + } + const hash = crypto.createHash('sha256').update(url).digest('hex'); const key = `attachment:${hash}`;