feat: 无标题智能纪要链接用最近会议名称兜底

This commit is contained in:
Benature
2026-11-29 00:45:33 +08:00
parent 313605f01b
commit 397ca3db40
3 changed files with 73 additions and 1 deletions

View File

@ -123,3 +123,60 @@ def test_fetch_calendar_events_normalizes_and_sorts_daily_instances():
assert request["calendarIds"] == ["calendar-synthetic"]
assert request["needsBriefEvents"] is True
assert request["endTime"] - request["startTime"] == 86_400
class FakeMeetingCalendarClient:
def __init__(self, begin_ts, end_ts):
self.begin_ts = begin_ts
self.end_ts = end_ts
def api(self, name, data):
if name == "calendars.GetUserPrimaryCalendarRequest":
return {"calendar": {"id": "calendar-synthetic"}}
assert name == "calendarevents.QueryInstanceRequest"
return {
"calendarEventInstance": [
{"eventRefId": "event-a", "beginTime": self.begin_ts, "endTime": self.end_ts}
],
"events": {
"event-a": {
"summary": "指数-金科定期AI业务讨论会",
"locations": [],
"isDeleted": False,
}
},
}
def test_untitled_ai_notes_link_falls_back_to_nearest_meeting_name():
tz = ZoneInfo("Asia/Shanghai")
begin = int(datetime(2026, 11, 17, 14, 0, tzinfo=tz).timestamp())
end = int(datetime(2026, 11, 17, 15, 0, tzinfo=tz).timestamp())
minutes_ts = int(datetime(2026, 11, 17, 15, 15, tzinfo=tz).timestamp())
docx_ts = int(datetime(2026, 11, 17, 17, 38, tzinfo=tz).timestamp())
storage = SnifferStorage(url="sqlite:///:memory:")
storage.save_message({
"msg_id": "minutes-1", "chat_id": AI_NOTES_CHAT_ID, "chat_type": 2,
"from_id": "bot", "msg_type": 14, "create_time": minutes_ts,
"content": (
"[卡片]\nMeeting recording completed"
"Topic: 指数-金科定期AI业务讨论会Owner: 万轶伦\n"
"https://efund.feishu.cn/minutes/m1"
),
})
storage.save_message({
"msg_id": "docx-1", "chat_id": AI_NOTES_CHAT_ID, "chat_type": 2,
"from_id": "bot", "msg_type": 4, "create_time": docx_ts,
"content": "https://efund.feishu.cn/docx/d1",
})
client = FakeMeetingCalendarClient(begin, end)
events, unmatched = fetch_calendar_events(
client, date(2026, 11, 17), tz, storage=storage
)
assert events[0]["url"].startswith("https://efund.feishu.cn/minutes/m1")
assert any(link["url"].startswith("https://efund.feishu.cn/docx/d1") for link in unmatched)
docx = next(link for link in unmatched if "docx/d1" in link["url"])
assert docx["topic"] == "指数-金科定期AI业务讨论会"