Skip to content

Commit 085d808

Browse files
committed
fix: add username to comments
1 parent d91435d commit 085d808

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/backend/src/services/CommentService.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const APIError = require("../api/APIError");
22
const FSNodeParam = require("../api/filesystem/FSNodeParam");
3+
const { get_user } = require("../helpers");
34
const configurable_auth = require("../middleware/configurable_auth");
45
const { Endpoint } = require("../util/expressutil");
56
const BaseService = require("./BaseService");
@@ -98,6 +99,9 @@ class CommentService extends BaseService {
9899
uid: comment.uid,
99100
text: comment.text,
100101
created: comment.created_at,
102+
user: {
103+
username: comment.user?.username,
104+
},
101105
});
102106
}
103107

@@ -149,6 +153,12 @@ class CommentService extends BaseService {
149153
[await node.get('mysql-id')],
150154
);
151155

156+
for ( const comment of comments ) {
157+
const user_id = comment.user_id;
158+
const user = await get_user({ id: user_id });
159+
comment.user = user;
160+
}
161+
152162
return comments;
153163
}
154164
}

0 commit comments

Comments
 (0)