widget email 6
This commit is contained in:
parent
582c69a96d
commit
8065e088eb
@ -19,12 +19,14 @@ export async function GET(req: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// First, try to get the user's Nextcloud ID using the Keycloak token
|
||||
// First, try to get the user's Nextcloud ID using the OCS API
|
||||
const userInfoResponse = await fetch(`${nextcloudUrl}/ocs/v2.php/cloud/user`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${session.accessToken}`,
|
||||
'Accept': 'application/json',
|
||||
'OCS-APIRequest': 'true',
|
||||
'Content-Type': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
});
|
||||
|
||||
@ -32,7 +34,8 @@ export async function GET(req: NextRequest) {
|
||||
console.error('Failed to get user info:', {
|
||||
status: userInfoResponse.status,
|
||||
statusText: userInfoResponse.statusText,
|
||||
url: userInfoResponse.url
|
||||
url: userInfoResponse.url,
|
||||
headers: Object.fromEntries(userInfoResponse.headers.entries())
|
||||
});
|
||||
|
||||
if (userInfoResponse.status === 401) {
|
||||
@ -56,12 +59,14 @@ export async function GET(req: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// Now try to access the Mail app
|
||||
const response = await fetch(`${nextcloudUrl}/index.php/apps/mail/api/accounts`, {
|
||||
// Now try to access the Mail app using OCS API
|
||||
const response = await fetch(`${nextcloudUrl}/ocs/v2.php/apps/mail/api/v1/accounts`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${session.accessToken}`,
|
||||
'Accept': 'application/json',
|
||||
'OCS-APIRequest': 'true',
|
||||
'Content-Type': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
});
|
||||
|
||||
@ -69,7 +74,8 @@ export async function GET(req: NextRequest) {
|
||||
console.error('Mail app check failed:', {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
url: response.url
|
||||
url: response.url,
|
||||
headers: Object.fromEntries(response.headers.entries())
|
||||
});
|
||||
|
||||
if (response.status === 401) {
|
||||
@ -82,7 +88,8 @@ export async function GET(req: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
const accounts = await response.json();
|
||||
const data = await response.json();
|
||||
const accounts = data?.ocs?.data || [];
|
||||
|
||||
// For now, return a success response with an empty array
|
||||
// We'll implement the actual message fetching once we confirm the correct endpoint
|
||||
|
||||
Loading…
Reference in New Issue
Block a user