update widget token mail 2
This commit is contained in:
parent
20bddf3fca
commit
5203045d8b
@ -9,13 +9,19 @@ export async function GET() {
|
|||||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session.user?.email) {
|
// Debug log to see all session data
|
||||||
return NextResponse.json({ error: "No email found in session" }, { status: 400 });
|
console.log('Session data:', {
|
||||||
|
user: session.user,
|
||||||
|
accessToken: session.accessToken ? 'present' : 'missing'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!session.user?.username) {
|
||||||
|
return NextResponse.json({ error: "No username found in session" }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the user's info from Rocket.Chat using their email
|
// Get the user's info from Rocket.Chat using their username
|
||||||
const userInfoResponse = await fetch(
|
const userInfoResponse = await fetch(
|
||||||
`https://parole.slm-lab.net/api/v1/users.info?email=${encodeURIComponent(session.user.email)}`,
|
`https://parole.slm-lab.net/api/v1/users.info?username=${encodeURIComponent(session.user.username)}`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
@ -30,7 +36,8 @@ export async function GET() {
|
|||||||
console.error('Rocket.Chat user info error:', {
|
console.error('Rocket.Chat user info error:', {
|
||||||
status: userInfoResponse.status,
|
status: userInfoResponse.status,
|
||||||
statusText: userInfoResponse.statusText,
|
statusText: userInfoResponse.statusText,
|
||||||
email: session.user.email,
|
username: session.user.username,
|
||||||
|
response: await userInfoResponse.text().catch(() => 'Could not get response text')
|
||||||
});
|
});
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: "Failed to fetch user info" },
|
{ error: "Failed to fetch user info" },
|
||||||
@ -57,6 +64,7 @@ export async function GET() {
|
|||||||
console.error('Rocket.Chat subscriptions error:', {
|
console.error('Rocket.Chat subscriptions error:', {
|
||||||
status: subscriptionsResponse.status,
|
status: subscriptionsResponse.status,
|
||||||
statusText: subscriptionsResponse.statusText,
|
statusText: subscriptionsResponse.statusText,
|
||||||
|
response: await subscriptionsResponse.text().catch(() => 'Could not get response text')
|
||||||
});
|
});
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: "Failed to fetch subscriptions" },
|
{ error: "Failed to fetch subscriptions" },
|
||||||
@ -93,6 +101,12 @@ export async function GET() {
|
|||||||
roomType: room.t,
|
roomType: room.t,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
console.error('Failed to fetch message:', {
|
||||||
|
roomId: room._id,
|
||||||
|
messageId: room.lastMessage._id,
|
||||||
|
status: messageResponse.status,
|
||||||
|
response: await messageResponse.text().catch(() => 'Could not get response text')
|
||||||
|
});
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user