From 085d808817e985f2bc52b7a91a31991ca3b2e89f Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Thu, 14 Nov 2024 18:09:38 -0500 Subject: [PATCH] fix: add username to comments --- src/backend/src/services/CommentService.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/src/services/CommentService.js b/src/backend/src/services/CommentService.js index f71b1a33..3420ccd3 100644 --- a/src/backend/src/services/CommentService.js +++ b/src/backend/src/services/CommentService.js @@ -1,5 +1,6 @@ const APIError = require("../api/APIError"); const FSNodeParam = require("../api/filesystem/FSNodeParam"); +const { get_user } = require("../helpers"); const configurable_auth = require("../middleware/configurable_auth"); const { Endpoint } = require("../util/expressutil"); const BaseService = require("./BaseService"); @@ -98,6 +99,9 @@ class CommentService extends BaseService { uid: comment.uid, text: comment.text, created: comment.created_at, + user: { + username: comment.user?.username, + }, }); } @@ -149,6 +153,12 @@ class CommentService extends BaseService { [await node.get('mysql-id')], ); + for ( const comment of comments ) { + const user_id = comment.user_id; + const user = await get_user({ id: user_id }); + comment.user = user; + } + return comments; } }