Files
thoughts/thoughts-frontend/components/remote-user-profile/profile-card.tsx
Gabriel Kaszewski 84edf58de6
Some checks failed
lint / lint (push) Failing after 9m26s
test / unit (push) Successful in 16m3s
fix(federation): fix 27 AP bugs, gaps, and inconsistencies
Round 1 — 18 bug fixes:
- remote likes/boosts now persist in engagement tables
- intern_remote_actor uses name@domain, expanded username to VARCHAR(255)
- PgRemoteActorRepository upsert/find now handles all fields
- update_following_status no longer a no-op, count_followers counts all
- accept/reject follow publishes event before DB mark (atomicity)
- fetch_outbox_page follows pagination via next links
- actor URL canonicalized to /users/{uuid}
- content_to_html escapes single quotes
- WebFinger accepts application/ld+json type
- try_from_ap accepts Article and Page object types
- feed SQL uses parameterized viewer UUID instead of format!
- content cap raised from 500 to 5000 chars
- also_known_as changed from Option<String> to Vec<String>
- connections fetch always triggers from page 1

Round 2 — 9 gap fixes:
- on_announce_removed handler deletes boost row on Undo(Announce)
- on_update handles Person/Service/Group actor profile updates
- sync_remote_actor_to_user syncs remote_actors → users on create/update
- FederationBlockPort: block_by_username sends Block activity to remote
- domain RemoteActor gains inbox_url, shared_inbox_url fields
- remote_actors attachment column (JSONB) with read/write
- .well-known/host-meta endpoint
- 256KB body limit on AP inbox routes
- outbox cleanup job (7-day retention, hourly sweep)
2026-05-29 11:28:40 +02:00

104 lines
3.0 KiB
TypeScript

import Link from "next/link";
import { ExternalLink } from "lucide-react";
import { ReactNode } from "react";
import { RemoteActor } from "@/lib/api";
import { UserAvatar } from "@/components/user-avatar";
import { Button } from "@/components/ui/button";
interface ProfileCardProps {
actor: RemoteActor;
/** Slot rendered next to the avatar (e.g. follow/unfollow button). */
action?: ReactNode;
}
export function ProfileCard({ actor, action }: ProfileCardProps) {
let hostname: string | null = null;
try {
if (actor.url) hostname = new URL(actor.url).hostname;
} catch {
hostname = actor.url;
}
return (
<>
<div className="flex justify-between items-start">
<div className="w-24 h-24 rounded-full border-4 border-background shrink-0">
<UserAvatar
src={actor.avatarUrl}
alt={actor.displayName}
className="w-full h-full"
/>
</div>
{action}
</div>
<div className="mt-4 min-w-0">
<h1 className="text-2xl font-bold truncate">
{actor.displayName ?? actor.handle}
</h1>
<p className="text-sm text-muted-foreground truncate">{actor.handle}</p>
</div>
{actor.bio && (
<div
className="mt-4 text-sm [&_a]:underline [&_a]:text-primary [&_p]:mb-2"
dangerouslySetInnerHTML={{ __html: actor.bio }}
/>
)}
<Button asChild variant="outline" size="sm" className="mt-4 w-full">
<Link
href={actor.url}
target="_blank"
rel="noopener noreferrer"
className="flex items-center overflow-hidden"
>
<ExternalLink className="mr-2 h-4 w-4 shrink-0" />
<span className="truncate">{hostname}</span>
</Link>
</Button>
{actor.alsoKnownAs.length > 0 && (
<p className="mt-2 text-xs text-muted-foreground">
Also known as:{" "}
{actor.alsoKnownAs.map((aka, i) => (
<span key={aka}>
{i > 0 && ", "}
<Link
href={aka}
target="_blank"
rel="noopener noreferrer"
className="underline"
>
{aka}
</Link>
</span>
))}
</p>
)}
{actor.attachment.length > 0 && (
<div className="mt-4 space-y-0 text-sm">
{actor.attachment.map((field) => (
<div
key={field.name}
className="grid grid-cols-[minmax(0,5rem)_1fr] gap-2 border-t py-1"
>
<span
className="font-medium text-muted-foreground truncate"
title={field.name}
>
{field.name}
</span>
<span
className="break-all min-w-0 [&_a]:underline [&_a]:text-primary"
dangerouslySetInnerHTML={{ __html: field.value }}
/>
</div>
))}
</div>
)}
</>
);
}