auto-sync: 2026-05-18 13:05:42

This commit is contained in:
cfdaily
2026-05-18 13:05:42 +08:00
parent 148ef6e417
commit 96753da796
+42
View File
@@ -100,6 +100,48 @@ async def list_mail(
return {"mails": mails, "total": len(mails)}
@router.get("/agents/list")
async def list_mail_agents():
"""列出参与过 Mail 的所有 Agent(用于筛选)"""
q = _q()
conn = q._conn()
try:
senders = conn.execute(
"SELECT DISTINCT assigned_by FROM tasks WHERE assigned_by IS NOT NULL"
).fetchall()
receivers = conn.execute(
"SELECT DISTINCT assignee FROM tasks WHERE assignee IS NOT NULL"
).fetchall()
agents = list(set(
[r["assigned_by"] for r in senders] +
[r["assignee"] for r in receivers]
))
agents.sort()
return {"agents": agents}
finally:
conn.close()
@router.get("/summary")
async def mail_summary():
"""Mail 摘要(未读数、总数)"""
bb = _bb()
all_tasks = bb.list_tasks()
total = len(all_tasks)
unread = 0
by_type: Dict[str, int] = {}
for t in all_tasks:
meta = _mail_meta(t)
if not meta.get("is_read", False):
unread += 1
mtype = meta.get("type", "inform")
by_type[mtype] = by_type.get(mtype, 0) + 1
return {"total": total, "unread": unread, "by_type": by_type}
@router.get("/{mail_id}")
async def get_mail(mail_id: str):
"""Mail 详情"""