From 57353f6c31d9aa694f3040d3f172694b132a1fa3 Mon Sep 17 00:00:00 2001 From: Alma Date: Thu, 10 Apr 2025 00:03:26 +0200 Subject: [PATCH] update widget token mail 13 --- app/api/rocket-chat/messages/route.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/api/rocket-chat/messages/route.ts b/app/api/rocket-chat/messages/route.ts index c07c172b..95fb4c87 100644 --- a/app/api/rocket-chat/messages/route.ts +++ b/app/api/rocket-chat/messages/route.ts @@ -2,6 +2,9 @@ import { getServerSession } from "next-auth"; import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import { NextResponse } from "next/server"; +const ROCKET_CHAT_TOKEN = 'w91TYgkH-Z67Oz72usYdkW5TZLLRwnre7qyAhp7aHJB'; +const ROCKET_CHAT_USER_ID = 'Tpuww59PJKsrGNQJB'; + export async function GET() { try { const session = await getServerSession(authOptions); @@ -61,8 +64,9 @@ export async function GET() { `https://parole.slm-lab.net/api/v1/users.info?username=${username}`, { headers: { - 'X-Auth-Token': process.env.ROCKET_CHAT_TOKEN!, - 'X-User-Id': process.env.ROCKET_CHAT_USER_ID! + 'X-Auth-Token': ROCKET_CHAT_TOKEN, + 'X-User-Id': ROCKET_CHAT_USER_ID, + 'Content-Type': 'application/json' } } ); @@ -71,6 +75,7 @@ export async function GET() { console.error('Failed to get user info:', { status: userInfoResponse.status, statusText: userInfoResponse.statusText, + headers: userInfoResponse.headers, response: await userInfoResponse.text().catch(() => 'Could not get response text') }); return NextResponse.json( @@ -90,8 +95,9 @@ export async function GET() { 'https://parole.slm-lab.net/api/v1/subscriptions.get', { headers: { - 'X-Auth-Token': process.env.ROCKET_CHAT_TOKEN!, - 'X-User-Id': userInfo.user._id + 'X-Auth-Token': ROCKET_CHAT_TOKEN, + 'X-User-Id': ROCKET_CHAT_USER_ID, + 'Content-Type': 'application/json' } } ); @@ -122,8 +128,9 @@ export async function GET() { `https://parole.slm-lab.net/api/v1/chat.getMessage?msgId=${room.lastMessage._id}`, { headers: { - 'X-Auth-Token': process.env.ROCKET_CHAT_TOKEN!, - 'X-User-Id': userInfo.user._id + 'X-Auth-Token': ROCKET_CHAT_TOKEN, + 'X-User-Id': ROCKET_CHAT_USER_ID, + 'Content-Type': 'application/json' } } );