Loading packages/client/src/components/PixelWhoisSidebar.tsx +2 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ interface IPixel { interface IUser { sub: string; username: string; display_name?: string; picture_url?: string; profile_url?: string; Loading Loading @@ -179,12 +180,5 @@ const SmallCanvas = ({ } }, [surrounding]); return ( <canvas width={300} height={300} ref={(r) => (canvasRef.current = r)} {...props} /> ); return <canvas width={300} height={300} ref={canvasRef} {...props} />; }; packages/client/src/components/Profile/ProfileModal.tsx +8 −6 Original line number Diff line number Diff line Loading @@ -21,13 +21,15 @@ export const ProfileModal = () => { return; } api<{ user: IUser }>("/api/user/" + profile).then(({ status, data }) => { api<{ user: IUser }>("/api/user/" + encodeURIComponent(profile)).then( ({ status, data }) => { if (status === 200 && data.success) { setUser(data.user); } else { handleError({ status, data }); } }); } ); }, [profile]); return ( Loading packages/client/src/components/Profile/UserCard.tsx +4 −18 Original line number Diff line number Diff line Loading @@ -2,12 +2,13 @@ import { faMessage, faWarning } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Button, Link, Spinner, User } from "@nextui-org/react"; import { ClientConfig } from "@sc07-canvas/lib/src/net"; import { MouseEvent, useEffect, useMemo, useState } from "react"; import { MouseEvent, useEffect, useState } from "react"; import { toast } from "react-toastify"; import { useAppContext } from "../../contexts/AppContext"; export interface IUser { sub: string; username: string; display_name?: string; picture_url?: string; profile_url?: string; Loading Loading @@ -39,7 +40,7 @@ export const UserCard = ({ user }: { user: IUser }) => { setMessageStatus("loading"); fetch( `https://${config.chat.matrix_homeserver}/_matrix/client/v3/profile/${encodeURIComponent(`@${user.sub.replace("@", "=40")}:${config.chat.matrix_homeserver}`)}` `https://${config.chat.matrix_homeserver}/_matrix/client/v3/profile/${encodeURIComponent(`@${user.username.replace("@", "=40")}:${config.chat.matrix_homeserver}`)}` ) .then((req) => { if (req.status === 200) { Loading Loading @@ -72,26 +73,11 @@ export const UserCard = ({ user }: { user: IUser }) => { setProfile(user.sub); }; const name = useMemo(() => { if (!user || !user.sub) { return "Unknown"; } const regex = /^(.*)@/; const match = user.sub.match(regex); if (match) { return match[1]; } return "Unknown"; }, [user]); return ( <div className="flex flex-col gap-1"> <div className="flex flex-row space-between p-2"> <User name={user?.display_name || name} name={user?.display_name || user?.username} description={user?.sub || "Unknown"} avatarProps={{ showFallback: true, Loading packages/lib/src/net.ts +8 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,14 @@ export type AuthSession = { }; }; user: { /** * URL * @example https://grants.cafe/users/grant */ sub: string; /** * @example grant@grants.cafe */ username: string; display_name?: string; picture_url?: string; Loading packages/server/prisma/migrations/20250520015553_migrate_to_uri_users/migration.sql 0 → 100644 +8 −0 Original line number Diff line number Diff line /* Warnings: - Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty. */ -- AlterTable ALTER TABLE "User" ADD COLUMN "username" TEXT NOT NULL; Loading
packages/client/src/components/PixelWhoisSidebar.tsx +2 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ interface IPixel { interface IUser { sub: string; username: string; display_name?: string; picture_url?: string; profile_url?: string; Loading Loading @@ -179,12 +180,5 @@ const SmallCanvas = ({ } }, [surrounding]); return ( <canvas width={300} height={300} ref={(r) => (canvasRef.current = r)} {...props} /> ); return <canvas width={300} height={300} ref={canvasRef} {...props} />; };
packages/client/src/components/Profile/ProfileModal.tsx +8 −6 Original line number Diff line number Diff line Loading @@ -21,13 +21,15 @@ export const ProfileModal = () => { return; } api<{ user: IUser }>("/api/user/" + profile).then(({ status, data }) => { api<{ user: IUser }>("/api/user/" + encodeURIComponent(profile)).then( ({ status, data }) => { if (status === 200 && data.success) { setUser(data.user); } else { handleError({ status, data }); } }); } ); }, [profile]); return ( Loading
packages/client/src/components/Profile/UserCard.tsx +4 −18 Original line number Diff line number Diff line Loading @@ -2,12 +2,13 @@ import { faMessage, faWarning } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Button, Link, Spinner, User } from "@nextui-org/react"; import { ClientConfig } from "@sc07-canvas/lib/src/net"; import { MouseEvent, useEffect, useMemo, useState } from "react"; import { MouseEvent, useEffect, useState } from "react"; import { toast } from "react-toastify"; import { useAppContext } from "../../contexts/AppContext"; export interface IUser { sub: string; username: string; display_name?: string; picture_url?: string; profile_url?: string; Loading Loading @@ -39,7 +40,7 @@ export const UserCard = ({ user }: { user: IUser }) => { setMessageStatus("loading"); fetch( `https://${config.chat.matrix_homeserver}/_matrix/client/v3/profile/${encodeURIComponent(`@${user.sub.replace("@", "=40")}:${config.chat.matrix_homeserver}`)}` `https://${config.chat.matrix_homeserver}/_matrix/client/v3/profile/${encodeURIComponent(`@${user.username.replace("@", "=40")}:${config.chat.matrix_homeserver}`)}` ) .then((req) => { if (req.status === 200) { Loading Loading @@ -72,26 +73,11 @@ export const UserCard = ({ user }: { user: IUser }) => { setProfile(user.sub); }; const name = useMemo(() => { if (!user || !user.sub) { return "Unknown"; } const regex = /^(.*)@/; const match = user.sub.match(regex); if (match) { return match[1]; } return "Unknown"; }, [user]); return ( <div className="flex flex-col gap-1"> <div className="flex flex-row space-between p-2"> <User name={user?.display_name || name} name={user?.display_name || user?.username} description={user?.sub || "Unknown"} avatarProps={{ showFallback: true, Loading
packages/lib/src/net.ts +8 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,14 @@ export type AuthSession = { }; }; user: { /** * URL * @example https://grants.cafe/users/grant */ sub: string; /** * @example grant@grants.cafe */ username: string; display_name?: string; picture_url?: string; Loading
packages/server/prisma/migrations/20250520015553_migrate_to_uri_users/migration.sql 0 → 100644 +8 −0 Original line number Diff line number Diff line /* Warnings: - Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty. */ -- AlterTable ALTER TABLE "User" ADD COLUMN "username" TEXT NOT NULL;