Supported public vs internal application comments, and moved some type dependencies to the shared lib

This commit is contained in:
2025-12-09 17:02:39 -05:00
parent e22f164097
commit f5a0df7795
9 changed files with 128 additions and 92 deletions

View File

@@ -90,15 +90,20 @@ export async function denyApplication(id: number) {
}
}
export async function getApplicationComments(appID: number): Promise<CommentRow[]> {
export async function getApplicationComments(appID: number, admin: boolean = false): Promise<CommentRow[]> {
const excludeAdmin = ' AND app.admin_only = false';
const whereClause = `WHERE app.application_id = ?${!admin ? excludeAdmin : ''}`;
return await pool.query(`SELECT app.id AS comment_id,
app.post_content,
app.poster_id,
app.post_time,
app.last_modified,
app.admin_only,
member.name AS poster_name
FROM application_comments AS app
INNER JOIN members AS member ON member.id = app.poster_id
WHERE app.application_id = ?;`,
${whereClause}`,
[appID]);
}