diff --git a/src/app/api/messages/route.ts b/src/app/api/messages/route.ts index 7a37f0d..e1d209c 100644 --- a/src/app/api/messages/route.ts +++ b/src/app/api/messages/route.ts @@ -61,7 +61,6 @@ export async function POST( } }); - await pusherServer.trigger(conversationId, 'messages:new', newMessage); const lastMessage = updatedConversation.messages[updatedConversation.messages.length - 1]; @@ -73,8 +72,6 @@ export async function POST( }) }) - - return NextResponse.json(newMessage) } catch (error) { console.log(error, 'ERROR_MESSAGES'); diff --git a/src/app/api/test/route.ts b/src/app/api/test/route.ts deleted file mode 100644 index 3aa7801..0000000 --- a/src/app/api/test/route.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { pusherServer } from "@/lib/pusher"; -import { NextResponse } from "next/server"; - -export async function POST( - request: Request -) { - try { - console.log('PUSHER_SERVER', pusherServer); - const response = await pusherServer.trigger('my-channel', 'my-event', { - message: 'hello world' - }); - - return NextResponse.json(response, { status: 200 }); - - } catch (error) { - console.log(error, 'ERROR_MESSAGES_SEEN'); - return new NextResponse("Something went wrong", { status: 500 }); - } -} \ No newline at end of file diff --git a/src/components/conversations/chat-body.tsx b/src/components/conversations/chat-body.tsx index ea4e059..afccf07 100644 --- a/src/components/conversations/chat-body.tsx +++ b/src/components/conversations/chat-body.tsx @@ -23,7 +23,7 @@ const ChatBody = ({ initialMessages }: ChatBodyProps) => { }, [conversationId]); useEffect(() => { - pusherClient.subscribe(conversationId[0]); + pusherClient.subscribe(conversationId as string); bottomRef?.current?.scrollIntoView(); const messageHandler = (message: FullMessageType) => { diff --git a/src/lib/pusher.ts b/src/lib/pusher.ts index 47b31d2..34b1bca 100644 --- a/src/lib/pusher.ts +++ b/src/lib/pusher.ts @@ -4,7 +4,7 @@ import PusherClient from 'pusher-js'; export const pusherServer = new PusherServer({ appId: process.env.PUSHER_APP_ID!, key: process.env.NEXT_PUBLIC_PUSHER_APP_KEY!, - secret: process.env.PUSHER_APP_SECRET!, + secret: process.env.PUSHER_SECRET!, cluster: 'ap2', useTLS: true, diff --git a/src/middleware.ts b/src/middleware.ts index ea7cbfe..f496a24 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -3,7 +3,6 @@ import NextAuth from "next-auth"; import authConfig from "./auth.config"; import { DEFAULT_LOGIN_REDIRECT, apiAuthPrefix, authRoutes, publicRoutes } from "@/routes" -import { getUserData } from "./data/session"; const { auth } = NextAuth(authConfig) //@ts-ignore