fix: suppress weather 400 noise, calendar sync email fallback

- Weather API returns empty hourly data (200) when lat/lon not configured,
  matching the 502 fix — no more browser console errors for weather
- Calendar sync route falls back to email lookup when session user ID
  doesn't match a DB record (handles stale JWT after DB restore/migration)

v1.81.14
This commit is contained in:
mARTin 2026-04-02 13:24:18 +02:00
parent 86c462c920
commit 2d785ea2bf
3 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "my-weekly-todo-list", "name": "my-weekly-todo-list",
"version": "1.81.13", "version": "1.81.14",
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -20,11 +20,19 @@ export async function POST(request: NextRequest) {
const timeMinDate = new Date(timeMin ?? Date.now()); const timeMinDate = new Date(timeMin ?? Date.now());
const timeMaxDate = new Date(timeMax ?? Date.now() + 7 * 24 * 60 * 60 * 1000); const timeMaxDate = new Date(timeMax ?? Date.now() + 7 * 24 * 60 * 60 * 1000);
const user = await prisma.user.findUnique({ let user = await prisma.user.findUnique({
where: { id: userId }, where: { id: userId },
include: { calendarConnections: true }, include: { calendarConnections: true },
}); });
// Fallback: session ID may be stale (e.g. after DB restore) — try by email
if (!user && session?.user?.email) {
user = await prisma.user.findUnique({
where: { email: session.user.email },
include: { calendarConnections: true },
}) ?? null;
}
if (!user) { if (!user) {
return NextResponse.json({ error: 'User not found' }, { status: 404 }); return NextResponse.json({ error: 'User not found' }, { status: 404 });
} }

View File

@ -22,7 +22,7 @@ export async function GET(request: NextRequest) {
}); });
if (!user?.weatherLat || !user.weatherLon) { if (!user?.weatherLat || !user.weatherLon) {
return NextResponse.json({ error: 'Weather not configured' }, { status: 400 }); return NextResponse.json({ hourly: {} });
} }
const { searchParams } = new URL(request.url); const { searchParams } = new URL(request.url);