Skip to content
20 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040)1/**
2 * People to invite, as the People page's invite form asks while someone
3 * types (components/people-picker.tsx): accounts whose username starts with
4 * `q`, or whose name contains it. A username, a name and an avatar each,
5 * never an email address. Signed in only. `-` is no workspace's name, so
6 * nothing else is ever found here.
7 */
8import type { Route } from "./+types/people-json";
9import { peopleQuery } from "../lib/people-search";
10import { identity } from "../lib/services.server";
11import { getViewer } from "../lib/session.server";
12
13export async function loader({ request, context }: Route.LoaderArgs) {
14 const viewer = getViewer(context);
15 const headers = { "cache-control": "private, max-age=30", vary: "Cookie" };
16 if (!viewer || (viewer.kind ?? "user") !== "user") return Response.json({ people: [] }, { status: 401, headers });
17 const query = peopleQuery(new URL(request.url).searchParams.get("q") ?? "");
18 const people = query ? await identity.findPeople(query, 8).catch(() => []) : [];
19 return Response.json({ people }, { headers });
20}

This file's history is long; its oldest lines are credited to the oldest commit read.