'use server'; import { unstable_rethrow } from 'next/navigation'; import { verifySession } from '@/lib/auth/dal'; import { markNotificationRead } from '@/lib/data/repositories/notification-repository'; export type NotificationActionResult = | { status: 'success' } | { status: 'error'; message: string }; export async function markNotificationReadAction( id: string ): Promise { await verifySession(); if (!id) { return { status: 'error', message: '요청이 올바르지 않습니다.' }; } try { await markNotificationRead(id); return { status: 'success' }; } catch (error) { // 이슈: 세션이 밀렸을 때 backendFetch가 던지는 redirect를 이 catch가 삼키면 안 된다. unstable_rethrow(error); return { status: 'error', message: error instanceof Error && error.message ? error.message : '알림을 읽음 처리하지 못했습니다.', }; } }