Improve RSS feed token authentication logging and error handling

This commit is contained in:
vvzvlad
2025-02-05 03:49:31 +03:00
parent 55e15e035e
commit 9d1440c0d9
+6 -3
View File
@@ -419,9 +419,12 @@ async def get_media(channel: str, post_id: int, file_unique_id: str, digest: str
@app.get("/rss/{channel}", response_class=Response)
@app.get("/rss/{channel}/{token}", response_class=Response)
async def get_rss_feed(channel: str, token: str | None = None, limit: int = 20):
if Config["token"] and token != Config["token"]:
logger.error(f"Invalid token for RSS feed: {token}")
#raise HTTPException(status_code=403, detail="Invalid token")
if Config["token"]:
if token != Config["token"]:
logger.error(f"Invalid token for RSS feed: {token}")
raise HTTPException(status_code=403, detail="Invalid token")
else:
logger.info(f"Valid token for RSS feed: {token}")
try:
rss_content = await generate_channel_rss(channel, client=client.client, limit=limit)