Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(notifications): return defaults instead of 500 for users with null preferences
Richie McIlroyc6c1eb2029eb
diff --git a/apps/web/app/api/notifications/preferences/route.ts b/apps/web/app/api/notifications/preferences/route.tsindex 3398e50e0..1c993175c 100644--- a/apps/web/app/api/notifications/preferences/route.ts+++ b/apps/web/app/api/notifications/preferences/route.ts@@ -36,11 +36,26 @@ export async function GET() {.where(eq(users.id, currentUser.id)).limit(1);- const parsedData = PreferencesSchema.parse(userPreferences?.preferences);+ const defaultNotifications = {+ notifications: {+ pauseComments: false,+ pauseReplies: false,+ pauseViews: false,+ pauseReactions: false,+ pauseAnonViews: false,+ },+ };++ const parsedData = PreferencesSchema.safeParse(+ userPreferences?.preferences ?? defaultNotifications,+ );- return NextResponse.json(parsedData.notifications, {- status: 200,- });+ return NextResponse.json(+ parsedData.success+ ? parsedData.data.notifications+ : defaultNotifications.notifications,+ { status: 200 },+ );} catch (error) {console.error("Error fetching user preferences:", error);return NextResponse.json(