From 582c69a96dac5bec394957aff3d207b34cbcd7f0 Mon Sep 17 00:00:00 2001 From: Alma Date: Sun, 13 Apr 2025 21:00:12 +0200 Subject: [PATCH] widget email 5 --- app/api/emails/route.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/api/emails/route.ts b/app/api/emails/route.ts index 46a29acd..897a7724 100644 --- a/app/api/emails/route.ts +++ b/app/api/emails/route.ts @@ -19,7 +19,7 @@ export async function GET(req: NextRequest) { ); } - // First, try to get the user's Nextcloud ID using the OIDC token + // First, try to get the user's Nextcloud ID using the Keycloak token const userInfoResponse = await fetch(`${nextcloudUrl}/ocs/v2.php/cloud/user`, { headers: { 'Authorization': `Bearer ${session.accessToken}`, @@ -57,11 +57,11 @@ export async function GET(req: NextRequest) { } // Now try to access the Mail app - const response = await fetch(`${nextcloudUrl}/ocs/v2.php/apps/mail/api/v1/accounts`, { + const response = await fetch(`${nextcloudUrl}/index.php/apps/mail/api/accounts`, { headers: { 'Authorization': `Bearer ${session.accessToken}`, 'Accept': 'application/json', - 'OCS-APIRequest': 'true', + 'Content-Type': 'application/json', }, }); @@ -82,7 +82,8 @@ export async function GET(req: NextRequest) { ); } - // If we get here, the Mail app is available + const accounts = await response.json(); + // For now, return a success response with an empty array // We'll implement the actual message fetching once we confirm the correct endpoint return NextResponse.json([]);