S4 review: voice-check checked_at is the oldest snapshot, not now (server-26#225)
The picker footer reads "Permissions checked N ago" from checked_at, but voice_check stamped it with the response time. A denied result is cached for 10 min, so a user who fixed the permission in Discord and reopened the picker saw "checked 2s ago · Needs fix" from a stale snapshot. checked_at now carries the oldest fetched_at behind the answer (now when there is none). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1ee1560383
commit
ec90a3f97c
@@ -87,6 +87,16 @@ def _channel_state(rows: list[dict], enabled: bool) -> str:
|
||||
return "no_bot"
|
||||
|
||||
|
||||
def _checked_at(snaps: dict) -> str:
|
||||
"""When Discord was last actually asked: the OLDEST cached snapshot behind
|
||||
this answer (a denied result is cached for 10 min), so the picker's
|
||||
"Permissions checked N ago" never calls a stale answer fresh (server-26#225
|
||||
S4). No snapshot (check off, no member bots) = now."""
|
||||
times = [s.fetched_at for s in snaps.values() if s is not None and getattr(s, "fetched_at", None)]
|
||||
ts = min(times) if times else time.time()
|
||||
return datetime.fromtimestamp(ts, timezone.utc).isoformat()
|
||||
|
||||
|
||||
async def voice_check(*, guild_id: str, org_id: Optional[str], node_id: Optional[str],
|
||||
channels: list[dict], channel_id: Optional[str], refresh: bool,
|
||||
with_token_ids: bool) -> dict:
|
||||
@@ -171,7 +181,7 @@ async def voice_check(*, guild_id: str, org_id: Optional[str], node_id: Optional
|
||||
"guild_id": guild_id,
|
||||
"node_id": node_id,
|
||||
"enabled": enabled,
|
||||
"checked_at": datetime.now(timezone.utc).isoformat(),
|
||||
"checked_at": _checked_at(snaps),
|
||||
"refreshed": refresh,
|
||||
"channels": out_channels,
|
||||
"invite": invite,
|
||||
|
||||
Reference in New Issue
Block a user