EPIC: Add content filtering via message flags

This commit is contained in:
vvzvlad
2025-02-09 03:53:52 +03:00
parent 1512c09f1b
commit 344052e00e
4 changed files with 120 additions and 63 deletions
+3 -4
View File
@@ -520,21 +520,20 @@ 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 = 50, output_type: str = 'rss'):
async def get_rss_feed(channel: str, token: str | None = None, limit: int = 50, output_type: str = 'rss', exclude_flags: str | None = None):
if Config["token"]:
if token != Config["token"]:
logger.error(f"Invalid token for RSS feed: {token}, expected: {Config['token']}")
raise HTTPException(status_code=403, detail="Invalid token")
else:
logger.info(f"Valid token for RSS feed: {token}")
while True:
try:
if output_type == 'rss':
rss_content = await generate_channel_rss(channel, client=client.client, limit=limit)
rss_content = await generate_channel_rss(channel, client=client.client, limit=limit, exclude_flags=exclude_flags)
return Response(content=rss_content, media_type="application/xml")
elif output_type == 'html':
rss_content = await generate_channel_html(channel, client=client.client, limit=limit)
rss_content = await generate_channel_html(channel, client=client.client, limit=limit, exclude_flags=exclude_flags)
return Response(content=rss_content, media_type="text/html")
except ValueError as e:
error_message = f"Invalid parameters for RSS feed generation: {str(e)}"