Skip to content

Commit

Permalink
chore: add reply user field (#2121)
Browse files Browse the repository at this point in the history
  • Loading branch information
lizheming authored Feb 21, 2024
1 parent e221d7b commit bbaa7f3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/server/src/controller/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,21 @@ module.exports = class extends BaseRest {
.reverse(),
);

const childCommentsMap = new Map();

childCommentsMap.set(cmt.objectId, cmt);
cmt.children.forEach((c) => childCommentsMap.set(c.objectId, c));

cmt.children.forEach((c) => {
const parent = childCommentsMap.get(c.pid);

c.reply_user = {
nick: parent.nick,
link: parent.link,
avatar: parent.avatar,
};
});

return cmt;
}),
),
Expand Down

0 comments on commit bbaa7f3

Please sign in to comment.