Enhance Discord authentication and guild management by implementing caching for user and guild data to reduce API calls and improve performance. Update error handling for Discord API responses and refactor the guilds listing logic in the dashboard to streamline data retrieval. Adjust retry logic for rate limits and improve session error handling in the authentication flow.
This commit is contained in:
@@ -14,7 +14,7 @@ from utils.db_paths import db_path, jsondb_path
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||
from api.dependencies import get_bot, limiter
|
||||
from api.discord_auth import require_discord_session, get_manageable_guild_ids
|
||||
from api.discord_auth import get_manageable_guild_ids, get_discord_headers
|
||||
from api.db_manager import db_manager
|
||||
from api.schemas import (
|
||||
GuildSummary, GuildDetails, PrefixConfig, AutomodConfig,
|
||||
@@ -46,8 +46,11 @@ router = APIRouter()
|
||||
async def list_guilds(request: Request, bot: "Axiom" = Depends(get_bot)):
|
||||
"""
|
||||
Lists guilds the bot is in, filtered to those the caller can manage on Discord.
|
||||
Session is already verified by middleware — only fetch manageable guild IDs here.
|
||||
"""
|
||||
token, _ = await require_discord_session(request)
|
||||
token, _ = get_discord_headers(request)
|
||||
if not token:
|
||||
raise HTTPException(status_code=403, detail="X-Discord-Access-Token header is required.")
|
||||
manageable_ids = await get_manageable_guild_ids(token)
|
||||
|
||||
guilds_list = []
|
||||
|
||||
Reference in New Issue
Block a user