From 7e2151b5ff65b468059406d58d4bf2a835c62eed Mon Sep 17 00:00:00 2001 From: Alma Date: Sun, 13 Apr 2025 00:25:57 +0200 Subject: [PATCH] widget parole 8 --- app/api/rocket-chat/messages/route.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/api/rocket-chat/messages/route.ts b/app/api/rocket-chat/messages/route.ts index af616d54..eea2391c 100644 --- a/app/api/rocket-chat/messages/route.ts +++ b/app/api/rocket-chat/messages/route.ts @@ -108,13 +108,18 @@ export async function GET(request: Request) { }); // Get user's subscriptions using admin token - const subscriptionsResponse = await fetch(`${baseUrl}/api/v1/subscriptions.list`, { + const subscriptionsResponse = await fetch(`${baseUrl}/api/v1/subscriptions.get`, { method: 'GET', - headers: adminHeaders + headers: { + ...adminHeaders, + 'Accept': 'application/json' + } }); if (!subscriptionsResponse.ok) { console.error('Failed to get subscriptions:', subscriptionsResponse.status); + const errorText = await subscriptionsResponse.text(); + console.error('Subscriptions error details:', errorText); return new Response(JSON.stringify({ error: 'Failed to get subscriptions' }), { status: subscriptionsResponse.status, headers: { 'Content-Type': 'application/json' }, @@ -150,13 +155,18 @@ export async function GET(request: Request) { try { // Get the latest messages from the room const messagesResponse = await fetch( - `${baseUrl}/api/v1/channels.messages?roomId=${subscription.rid}&count=1`, { + `${baseUrl}/api/v1/chat.getMessage?roomId=${subscription.rid}`, { method: 'GET', - headers: adminHeaders + headers: { + ...adminHeaders, + 'Accept': 'application/json' + } }); if (!messagesResponse.ok) { console.error(`Failed to get messages for room ${subscription.name}:`, messagesResponse.status); + const errorText = await messagesResponse.text(); + console.error(`Messages error details for ${subscription.name}:`, errorText); continue; }