WebSocket Secure
This commit is contained in:
@@ -10,7 +10,7 @@ import { ProfileSettings } from "@/types/settings";
|
||||
export async function POST(req: NextRequest) {
|
||||
const url = new URL(req.url);
|
||||
const token = req.cookies.get("token")?.value;
|
||||
const { username, display_name, avatar_url } =
|
||||
const { username, display_name, avatar_url, node_address } =
|
||||
(await req.json()) as ProfileSettings;
|
||||
|
||||
if (!token)
|
||||
@@ -21,7 +21,10 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
if (!username || !display_name || !avatar_url)
|
||||
return NextResponse.json(
|
||||
{ message: "Invalid body, requires username, display_name, avatar_url" },
|
||||
{
|
||||
message:
|
||||
"Invalid body, requires username, display_name, avatar_url, node_address",
|
||||
},
|
||||
{ status: StatusCodes.BAD_REQUEST }
|
||||
);
|
||||
|
||||
@@ -41,6 +44,7 @@ export async function POST(req: NextRequest) {
|
||||
username,
|
||||
display_name,
|
||||
avatar_url,
|
||||
node_address,
|
||||
})
|
||||
.eq("id", user.id);
|
||||
|
||||
@@ -85,7 +89,7 @@ export async function GET(req: NextRequest) {
|
||||
|
||||
const { data: profile } = await supabase
|
||||
.from("profiles")
|
||||
.select("id, username, display_name, avatar_url")
|
||||
.select("id, username, display_name, avatar_url, node_address")
|
||||
.eq("id", user_id)
|
||||
.maybeSingle();
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useRef, useState } from "react";
|
||||
import MessageBox from "@/components/MessageBox";
|
||||
import AppSidebar from "@/components/Sidebar";
|
||||
import { Message } from "@/types/types";
|
||||
import useUser, { User } from "@/hooks/get-user";
|
||||
import { NumberMap, StringMap } from "@/types/typeUtils";
|
||||
import auth, { makeAddress } from "@/lib/auth";
|
||||
import { UserProfile } from "@/hooks/get-user";
|
||||
import { StringMap } from "@/types/typeUtils";
|
||||
import { useParams } from "next/navigation";
|
||||
|
||||
// In this testing instance we are assuming that the target's node is localhost
|
||||
@@ -16,8 +15,8 @@ export default function DMs() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const wsRef = useRef<WebSocket | null>(null);
|
||||
const [messages, setMessages] = useState<Message[]>([]);
|
||||
const [userList, setUserList] = useState<StringMap<User>>({});
|
||||
const [user, setUser] = useState<User | undefined>();
|
||||
const [userList, setUserList] = useState<StringMap<UserProfile>>({});
|
||||
const [user, setUser] = useState<UserProfile | undefined>();
|
||||
|
||||
return (
|
||||
<AppSidebar
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import { useRef, useState } from "react";
|
||||
import AppSidebar from "@/components/Sidebar";
|
||||
import { User } from "@/hooks/get-user";
|
||||
import { UserProfile } from "@/hooks/get-user";
|
||||
import { StringMap } from "@/types/typeUtils";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import ProfilePicture from "@/components/ProfilePicture";
|
||||
|
||||
export default function Chat() {
|
||||
const wsRef = useRef<WebSocket | null>(null);
|
||||
const [userList, setUserList] = useState<StringMap<User>>({});
|
||||
const [userList, setUserList] = useState<StringMap<UserProfile>>({});
|
||||
|
||||
return (
|
||||
<AppSidebar
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useParams } from "next/navigation";
|
||||
import MessageBox from "@/components/MessageBox";
|
||||
import AppSidebar from "@/components/Sidebar";
|
||||
import { Message, Server as ServerType } from "@/types/types";
|
||||
import { User } from "@/hooks/get-user";
|
||||
import { UserProfile } from "@/hooks/get-user";
|
||||
import { StringMap } from "@/types/typeUtils";
|
||||
import auth, { makeAddress } from "@/lib/auth";
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function Server() {
|
||||
const wsNodeRef = useRef<WebSocket | null>(null);
|
||||
const [server, setServer] = useState<undefined | ServerType>();
|
||||
const [messages, setMessages] = useState<Message[]>([]);
|
||||
const [userList, setUserList] = useState<StringMap<User>>({});
|
||||
const [userList, setUserList] = useState<StringMap<UserProfile>>({});
|
||||
|
||||
useEffect(() => {
|
||||
if (!ip) return;
|
||||
|
||||
Reference in New Issue
Block a user