From 29dcaad89c49126b5d0664b1066583c35e275edd Mon Sep 17 00:00:00 2001 From: Cecilia Lindskog Date: Wed, 27 Jan 2021 10:57:04 +0100 Subject: [PATCH] Fix issue with feedId --- src/models.js | 16 +++++++++++----- src/views/index.js | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/models.js b/src/models.js index 92a0750..42ad705 100644 --- a/src/models.js +++ b/src/models.js @@ -693,8 +693,6 @@ module.exports = ({ cooler, isPublic }) => { }; const getUserInfo = async (feedId) => { - const id = feedId; - const pendingName = models.about.name(feedId); const pendingAvatarMsg = models.about.image(feedId); @@ -708,9 +706,17 @@ module.exports = ({ cooler, isPublic }) => { const avatarUrl = `/image/64/${encodeURIComponent(avatarId)}`; - return { name, id, avatarId, avatarUrl }; + return { name, feedId, avatarId, avatarUrl }; }; + function getRecipientFeedId(recipient) { + if (typeof recipient === "string") { + return recipient; + } else { + return recipient.link; + } + } + const transform = (ssb, messages, myFeedId) => Promise.all( messages.map(async (msg) => { @@ -853,8 +859,8 @@ module.exports = ({ cooler, isPublic }) => { if (isPrivate(msg)) { msg.value.meta.recpsInfo = await Promise.all( - msg.value.content.recps.map((feedId) => { - return getUserInfo(feedId); + msg.value.content.recps.map((recipient) => { + return getUserInfo(getRecipientFeedId(recipient)); }) ); } diff --git a/src/views/index.js b/src/views/index.js index df26d14..d144ad6 100644 --- a/src/views/index.js +++ b/src/views/index.js @@ -399,7 +399,7 @@ const post = ({ msg, aside = false }) => { recpsInfo.forEach(function (recp) { recps.push( a( - { href: `/author/${encodeURIComponent(recp.id)}` }, + { href: `/author/${encodeURIComponent(recp.feedId)}` }, img({ class: "avatar", src: recp.avatarUrl, alt: "" }) ) );