v3: added comment likes, added votes/likes list view, added db migrations mechanism, updated project dependencies
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 42s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 42s
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
import { linkAttachments } from "./attachment-service.ts";
|
||||
|
||||
const SELECT_COLS =
|
||||
`c.id, c.dump_id, c.user_id, c.parent_id, c.body, c.created_at, c.updated_at, c.deleted,
|
||||
`c.id, c.dump_id, c.user_id, c.parent_id, c.body, c.created_at, c.updated_at, c.deleted, c.like_count,
|
||||
u.username as author_username, u.avatar_mime as author_avatar_mime`;
|
||||
|
||||
function fetchComment(commentId: string): Comment {
|
||||
@@ -32,6 +32,16 @@ function fetchComment(commentId: string): Comment {
|
||||
return commentRowToApi(row);
|
||||
}
|
||||
|
||||
export function getCommentDumpId(commentId: string): string {
|
||||
const row = db.prepare(`SELECT dump_id FROM comments WHERE id = ?;`).get(
|
||||
commentId,
|
||||
) as { dump_id: string } | undefined;
|
||||
if (!row) {
|
||||
throw new APIException(APIErrorCode.NOT_FOUND, 404, "Comment not found");
|
||||
}
|
||||
return row.dump_id;
|
||||
}
|
||||
|
||||
export function getComments(dumpId: string): Comment[] {
|
||||
const rows = db.prepare(
|
||||
`SELECT ${SELECT_COLS} FROM comments c JOIN users u ON c.user_id = u.id
|
||||
|
||||
Reference in New Issue
Block a user