fix: add username to comments

This commit is contained in:
KernelDeimos 2024-11-14 18:09:38 -05:00
parent d91435db57
commit 085d808817

View File

@ -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;
}
}