S7 review: align OAuth UI with S6's actual contract (server-26#225)
- complete: S6 returns streams_stopped, not stopped — the "N radio channels were stopped" note never showed. - start: bot name is nested as bot.name. - "The bot for a system" with an org-owned preferred bot now sends token_id (S6 accepts it today); system_id only for a platform-pinned pool bot, which still needs S6 to accept system_id. - A 404 for one chosen bot no longer hides Connect and the picker (the message told the user to try Automatic, but the button was gone). - Server count uses GET /tokens' per-bot server_cap when present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dd3e5c9655
commit
eaa0be07c5
@@ -28,10 +28,17 @@ const SELECT =
|
||||
|
||||
// Option values for the bot picker: "" = let C2 choose, "tok:<id>" = one of
|
||||
// the org's own bots, "sys:<id>" = whichever bot is preferred for that system.
|
||||
function startRequest(choice: string): OAuthStartRequest {
|
||||
function startRequest(choice: string, data: OrgPreferredBots | null): OAuthStartRequest {
|
||||
const req: OAuthStartRequest = { return_to: "/settings/organization" };
|
||||
if (choice.startsWith("tok:")) req.token_id = choice.slice(4);
|
||||
else if (choice.startsWith("sys:")) req.system_id = choice.slice(4);
|
||||
else if (choice.startsWith("sys:")) {
|
||||
const id = choice.slice(4);
|
||||
// The org's own bot preferred for this system: name it by token_id, which
|
||||
// S6 already accepts. Only a platform-pinned pool bot needs system_id.
|
||||
const pref = data?.systems.find((s) => s.system_id === id)?.preferred_token_id;
|
||||
if (pref) req.token_id = pref;
|
||||
else req.system_id = id;
|
||||
}
|
||||
return req;
|
||||
}
|
||||
|
||||
@@ -125,18 +132,19 @@ export function DiscordServersCard({ canEdit, isAdmin }: { canEdit: boolean; isA
|
||||
setActionError(null);
|
||||
setJustLinked(null);
|
||||
try {
|
||||
const { url } = await startDiscordOAuth(startRequest(choice));
|
||||
const { url } = await startDiscordOAuth(startRequest(choice, choices));
|
||||
window.location.assign(url);
|
||||
// Leave the button in its busy state: the page is navigating to Discord.
|
||||
} catch (err) {
|
||||
if (err instanceof OAuthNotConfigured) {
|
||||
setOauthOff(true);
|
||||
setShowCode(true);
|
||||
setActionError(
|
||||
choice
|
||||
? "That bot can't connect servers yet. Try Automatic, or link with a code below."
|
||||
: "Connecting with Discord isn't set up yet. Link with a code below instead.",
|
||||
);
|
||||
if (choice) {
|
||||
// Only this bot is off: keep Connect and the picker so Automatic can be tried.
|
||||
setActionError("That bot can't connect servers yet. Try Automatic, or link with a code below.");
|
||||
} else {
|
||||
setOauthOff(true);
|
||||
setActionError("Connecting with Discord isn't set up yet. Link with a code below instead.");
|
||||
}
|
||||
} else {
|
||||
setActionError(parseC2Error(err).message);
|
||||
}
|
||||
|
||||
@@ -54,11 +54,12 @@ function Checks({ t }: { t: RadioBot }) {
|
||||
function ServerCount({ t, cap }: { t: RadioBot; cap: number }) {
|
||||
if (t.guild_ids == null) return null;
|
||||
const n = t.guild_ids.length;
|
||||
const full = t.org_id == null && n >= cap;
|
||||
const limit = t.server_cap ?? cap;
|
||||
const full = t.org_id == null && n >= limit;
|
||||
return (
|
||||
<div className={`text-xs mb-1 ${full || n >= DISCORD_UNVERIFIED_GUILD_LIMIT ? "text-sev-moderate" : "text-ink-muted"}`}>
|
||||
{n} of {DISCORD_UNVERIFIED_GUILD_LIMIT} servers
|
||||
{full && ` · full at ${cap}: Connect skips it, add another pool bot`}
|
||||
{full && ` · full at ${limit}: Connect skips it, add another pool bot`}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user