5, "try" => "find a friend", "wing" => "Identity", "title" => "Find a friend", "promise" => "Any app can search for people by name, including people who have never used it.", "block" => "rc_user_search(\$q) finds people by the start of their username or of any word of their name, across the whole platform.", "show" => function (?array $me): string { if (!$me) return '

Sign in to search for people.

'; return '
'; }, "api" => function (string $do, ?array $me, array $in, bool $post): ?array { if ($do !== "search") return null; if (!$me) return ["error" => "sign in to search", "status" => 401]; return ["users" => rc_user_search((string)($in["q"] ?? ""), 12)]; }, // rc-check is root's robot: it has an account but has never used the zoo. "check" => function (): array { $hits = array_column(rc_user_search("rc-check", 5), "username"); if (!in_array("rc-check", $hits, true)) return [false, "searching \"rc-check\" did not find root's robot, who has an account" . ($hits ? " (found: " . implode(", ", $hits) . ")" : "")]; return [true, "found @rc-check, who has an account but has never used the zoo"]; }, "script" => <<<'JS' document.getElementById("find")?.addEventListener("submit", async (ev) => { ev.preventDefault(); const out = document.getElementById("found"); const j = await zoo.call("/api/5/search?q=" + encodeURIComponent(ev.target.q.value)); out.innerHTML = j.error ? zoo.esc(j.error) : (j.users.length ? j.users.map(zoo.person).join("") : '

Nobody by that name.

'); }); JS, ];