프로필 썸네일 해제 시 메타 분리 통일·미디어 모달 다운로드(v0.0.92)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-12 10:56:26 +09:00
parent 16bb9370fa
commit c1242e1409
7 changed files with 71 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ import { createError, readBody } from 'h3'
import { z } from 'zod'
import { getUserById, isUsernameTaken, updateMemberProfile } from '../../repositories/member-repository'
import { requireMemberSession } from '../../utils/member-auth'
import { isManagedAvatarUrl, removeManagedAvatarAsset } from '../../utils/member-avatar'
const updateProfileSchema = z.object({
username: z.string().trim().min(1).max(30),
@@ -36,10 +37,26 @@ export default defineEventHandler(async (event) => {
})
}
const existing = await getUserById(session.userId)
if (!existing) {
throw createError({
statusCode: 404,
message: '회원 정보를 찾을 수 없습니다.'
})
}
const previousAvatarUrl = existing.avatarUrl || ''
const nextAvatarUrl = parsedBody.data.avatarUrl || ''
if (previousAvatarUrl && previousAvatarUrl !== nextAvatarUrl && isManagedAvatarUrl(previousAvatarUrl)) {
await removeManagedAvatarAsset(previousAvatarUrl)
}
const updated = await updateMemberProfile({
userId: session.userId,
username: parsedBody.data.username,
avatarUrl: parsedBody.data.avatarUrl
avatarUrl: nextAvatarUrl
})
if (!updated) {