v1.10.88 품질·보안 개선과 미디어 카탈로그 database 전환을 반영한다.

세션·로그인 제한, ZIP/업로드 스트리밍, CSP 최소 강제와 Report-Only, Playwright 격리 검증을 추가하고 미디어 목록을 reconcile 후 database 모드로 고정한다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-22 11:05:40 +09:00
parent 9bc0f0a90e
commit de767095ba
116 changed files with 8128 additions and 2933 deletions

View File

@@ -29,18 +29,24 @@ const getSql = () => getPostgresClient()
const isUndefinedTableError = (error) => String(error?.code || '') === '42P01'
/**
* 게시물 ID 조회
* 댓글 접근 가능한 게시물 ID 조회
* @param {ReturnType<typeof import('postgres').default>} sql - postgres 클라이언트
* @param {string} slug - 게시물 슬러그
* @param {boolean} includeMembership - 멤버십 게시물 허용 여부
* @returns {Promise<string | null>} 게시물 ID
*/
const findPublishedPostIdBySlug = async (sql, slug) => {
const findAccessiblePostIdBySlug = async (sql, slug, includeMembership = false) => {
const rows = await sql`
SELECT id
FROM posts
WHERE slug = ${slug}
AND status = 'published'
AND (
status = 'published'
OR (${includeMembership} = true AND status = 'members')
)
AND (
status = 'members'
OR
published_at IS NULL
OR published_at <= now()
)
@@ -55,14 +61,14 @@ const findPublishedPostIdBySlug = async (sql, slug) => {
* @param {string} slug - 게시물 슬러그
* @returns {Promise<Array<PostComment>>} 댓글 목록
*/
export const listPostCommentsBySlug = async (slug, viewerUserId = null) => {
export const listPostCommentsBySlug = async (slug, viewerUserId = null, includeMembership = false) => {
const sql = getSql()
if (!sql) {
return []
}
const postId = await findPublishedPostIdBySlug(sql, slug)
const postId = await findAccessiblePostIdBySlug(sql, slug, includeMembership)
if (!postId) {
throw createError({
statusCode: 404,
@@ -149,7 +155,7 @@ export const listPostCommentsBySlug = async (slug, viewerUserId = null) => {
/**
* 댓글 생성
* @param {{ slug: string, userId: string, body: string, parentId?: string | null }} input - 댓글 입력값
* @param {{ slug: string, userId: string, body: string, parentId?: string | null, includeMembership?: boolean }} input - 댓글 입력값
* @returns {Promise<PostComment>} 생성된 댓글
*/
export const createComment = async (input) => {
@@ -162,7 +168,7 @@ export const createComment = async (input) => {
})
}
const postId = await findPublishedPostIdBySlug(sql, input.slug)
const postId = await findAccessiblePostIdBySlug(sql, input.slug, Boolean(input.includeMembership))
if (!postId) {
throw createError({
statusCode: 404,
@@ -250,7 +256,7 @@ export const createComment = async (input) => {
/**
* 댓글 좋아요를 토글한다.
* @param {{ slug: string, commentId: string, userId: string }} input - 좋아요 입력값
* @param {{ slug: string, commentId: string, userId: string, includeMembership?: boolean }} input - 좋아요 입력값
* @returns {Promise<{ liked: boolean, likeCount: number }>} 좋아요 결과
*/
export const toggleCommentLike = async (input) => {
@@ -263,7 +269,7 @@ export const toggleCommentLike = async (input) => {
})
}
const postId = await findPublishedPostIdBySlug(sql, input.slug)
const postId = await findAccessiblePostIdBySlug(sql, input.slug, Boolean(input.includeMembership))
if (!postId) {
throw createError({
statusCode: 404,