Skip to content

Commit 6855ed4

Browse files
committed
v2.3.12A
1 parent 8634333 commit 6855ed4

8 files changed

Lines changed: 505 additions & 132 deletions

File tree

backend/app/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
users,
4040
weread,
4141
)
42+
from app.tasks.aps_tasks import send_daily_summary
4243
from app.tasks.broker import broker
4344
from app.tasks.task import send_feishu_message
4445
from app.utils import close_cache_redis, get_redis_lock
@@ -81,6 +82,7 @@ async def lifespan(app: FastAPI):
8182
app.state.redis, "bootstrap_notification", ttl=600
8283
):
8384
try:
85+
await send_daily_summary.kiq()
8486
await send_feishu_message.kiq()
8587
# await send_bootstrap_emails.kiq(admin_email=admin_email)
8688
app_logger.info("✅启动通知任务已添加到队列")

backend/app/models/mgmodel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,7 @@ class Settings:
128128
]
129129
bson_encoders: ClassVar[dict] = {PydanticObjectId: str}
130130
model_config = ConfigDict(arbitrary_types_allowed=True)
131+
132+
133+
class RssArticleGuidProjection(BaseModel):
134+
guid: str

backend/app/routers/rss.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,21 @@ async def parse_rss(
200200
logger.info(f"Redis缓存命中: {rss_url}")
201201
return APIResponse.ok(data=json.loads(cached_data))
202202
try:
203-
feed: feedparser.FeedParserDict = feedparser.parse(rss_url)
203+
# 异步获取feed内容,带超时控制
204+
async with httpx.AsyncClient(
205+
timeout=httpx.Timeout(10.0, connect=5.0), follow_redirects=True
206+
) as client:
207+
resp = await client.get(rss_url)
208+
resp.raise_for_status()
209+
content = resp.content
210+
211+
# 在线程池中解析内容
212+
import asyncio
213+
214+
loop = asyncio.get_running_loop()
215+
feed: feedparser.FeedParserDict = await loop.run_in_executor(
216+
None, feedparser.parse, content
217+
)
204218
if feed.bozo != 0:
205219
return APIResponse.error(message="无法解析RSS链接", code=400)
206220
feed_meta = _build_feed_meta(feed)
@@ -437,7 +451,21 @@ async def refresh_subscription(
437451
await redis.delete(redis_key)
438452

439453
try:
440-
feed: feedparser.FeedParserDict = feedparser.parse(rss_url)
454+
# 异步获取feed内容,带超时控制
455+
async with httpx.AsyncClient(
456+
timeout=httpx.Timeout(10.0, connect=5.0), follow_redirects=True
457+
) as client:
458+
resp = await client.get(rss_url)
459+
resp.raise_for_status()
460+
content = resp.content
461+
462+
# 在线程池中解析内容
463+
import asyncio
464+
465+
loop = asyncio.get_running_loop()
466+
feed: feedparser.FeedParserDict = await loop.run_in_executor(
467+
None, feedparser.parse, content
468+
)
441469
if feed.bozo != 0:
442470
return APIResponse.error(message="无法解析RSS链接", code=400)
443471
feed_meta = _build_feed_meta(feed)

backend/app/schemas/schemas.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ class RssMarkReadRequest(BaseModel):
451451

452452

453453
class TodoIn(BaseModel):
454+
"""Todo creation schema."""
455+
454456
text: str
455457
description: str | None = None
456458
dueDate: str | None = None # ISO date string # noqa: N815
@@ -463,6 +465,8 @@ class TodoIn(BaseModel):
463465

464466

465467
class TodoUpdate(BaseModel):
468+
"""Todo update schema."""
469+
466470
text: str | None = None
467471
description: str | None = None
468472
dueDate: str | None = None # noqa: N815
@@ -474,6 +478,8 @@ class TodoUpdate(BaseModel):
474478

475479

476480
class TodoOut(BaseModel):
481+
"""Todo output schema."""
482+
477483
id: str
478484
text: str
479485
completed: bool
@@ -484,3 +490,18 @@ class TodoOut(BaseModel):
484490
category: str | None = None
485491
archived: bool = False
486492
archivedAt: str | None = None # noqa: N815
493+
494+
495+
# --** Feishu Message Schemas *---
496+
class FeishuMessageContent(BaseModel):
497+
"""飞书消息内容模型"""
498+
499+
msg_type: str = "text"
500+
content: dict | None = None
501+
502+
503+
class FeishuRichTextContent(BaseModel):
504+
"""飞书富文本内容模型"""
505+
506+
msg_type: str = "post"
507+
content: dict | None = None

0 commit comments

Comments
 (0)