feat: Add missing comments.info endpoint, fix misnamed types

This commit is contained in:
Tom Moor
2023-12-29 10:13:22 -05:00
parent 08a787082f
commit 5d2a75c8e9
4 changed files with 88 additions and 15 deletions

View File

@@ -55,13 +55,34 @@ router.post(
}
);
router.post(
"comments.info",
auth(),
checkCommentingEnabled(),
validate(T.CommentsInfoSchema),
async (ctx: APIContext<T.CommentsInfoReq>) => {
const { id } = ctx.input.body;
const { user } = ctx.state.auth;
const comment = await Comment.findByPk(id, {
rejectOnEmpty: true,
});
authorize(user, "read", comment);
ctx.body = {
data: presentComment(comment),
policies: presentPolicies(user, [comment]),
};
}
);
router.post(
"comments.list",
auth(),
pagination(),
checkCommentingEnabled(),
validate(T.CollectionsListSchema),
async (ctx: APIContext<T.CollectionsListReq>) => {
validate(T.CommentsListSchema),
async (ctx: APIContext<T.CommentsListReq>) => {
const { sort, direction, documentId, collectionId } = ctx.input.body;
const { user } = ctx.state.auth;