From 9f4b92cc36f4e65cc30a5064e10e7c57726f5fd1 Mon Sep 17 00:00:00 2001 From: lashman Date: Sun, 22 Mar 2026 07:15:13 +0200 Subject: [PATCH] use admin linked user as comment author so avatar and name are correct --- packages/api/src/routes/comments.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/api/src/routes/comments.ts b/packages/api/src/routes/comments.ts index aef01f9..4814386 100644 --- a/packages/api/src/routes/comments.ts +++ b/packages/api/src/routes/comments.ts @@ -157,11 +157,19 @@ export default async function commentRoutes(app: FastifyInstance) { const cleanBody = body.body.replace(INVISIBLE_RE, ''); const isAdmin = !!req.adminId; + + // use admin's linked user as author when commenting as admin + let commentAuthorId = req.user!.id; + if (isAdmin) { + const adminUser = await prisma.adminUser.findUnique({ where: { id: req.adminId! }, select: { linkedUserId: true } }); + if (adminUser?.linkedUserId) commentAuthorId = adminUser.linkedUserId; + } + const comment = await prisma.comment.create({ data: { body: cleanBody, postId: post.id, - authorId: req.user!.id, + authorId: commentAuthorId, replyToId: body.replyToId ?? null, isAdmin, adminUserId: req.adminId ?? null,