Discord admin overview: no fallback org for explicitly unlinked servers

PR #218 (server-26#213 item 1) unlinks a server by clearing org_id and
stamping unlinked_at, and resolve_guild_org then refuses the fallback org.
The overview showed such a server as "Unlinked · fallback org" and offered it
in Add radio channel, where start_stream would 403. Mirror the rule here
(forward-compatible: unlinked_at does not exist on main yet). Also key each
stream row by the resolved guild id, and drop panel copy that pointed at a
"Needed" figure the page doesn't show / misstated the invite permissions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Logan Cusano
2026-10-04 21:35:48 -04:00
co-authored by Claude Opus 5.5
parent d3277c13e1
commit 31ca63b2a0
3 changed files with 22 additions and 6 deletions
+12
View File
@@ -115,3 +115,15 @@ def test_relinking_a_server_to_another_org_stops_its_live_channels(fs, monkeypat
# moved to a different org: its live channels are stopped
r = client.put("/discord/guilds/111/link", json={"org_id": "founding"}).json()
assert r["stopped"] == ["111:900"] and calls == [("111", "server linked to another organization")]
def test_explicitly_unlinked_server_gets_no_fallback_org(fs):
# server-26#218 unlinks by clearing org_id and stamping unlinked_at;
# resolve_guild_org then refuses the fallback, so the page must not offer it.
_seed(fs)
fs.put("discord_guilds", "444", {"guild_id": "444", "org_id": None, "unlinked_at": "2026-10-02T00:00:00+00:00"})
app.dependency_overrides[require_admin_token] = lambda: ADMIN
guilds = {g["guild_id"]: g for g in client.get("/discord/admin/overview").json()["guilds"]}
assert guilds["444"]["linked"] is False and guilds["444"]["acting_org_id"] is None
assert "_no_fallback" not in guilds["444"]
assert guilds["222"]["acting_org_id"] == "founding" # never-linked server keeps the fallback