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

@ -251,6 +251,7 @@ def fetch_calendar_events(
event_map = response.get("events") or {}
events = []
used_urls: set[str] = set()
event_end_times: list[tuple[int, str]] = []
for instance in response.get("calendarEventInstance") or []:
event = event_map.get(str(instance.get("eventRefId") or ""), {})
locations = event.get("locations") or []
@ -280,9 +281,23 @@ def fetch_calendar_events(
"url": ai_notes_url or native_url or manual_url,
}
)
event_end_times.append((event_end_ts, summary))
events.sort(key=lambda event: (event["begin"], event["summary"]))
# Collect unmatched links for separate display
unmatched_links = [
link for link in ai_notes_links if link["url"] not in used_urls
]
# Fall back to the nearest meeting name for untitled links (e.g. docx notices).
for link in unmatched_links:
if link.get("topic"):
continue
best_delta = None
best_summary = ""
for end_ts, summary in event_end_times:
delta = link["create_time"] - end_ts
if abs(delta) <= 21600 and (best_delta is None or abs(delta) < abs(best_delta)):
best_delta = delta
best_summary = summary
if best_summary:
link["topic"] = best_summary
return events, unmatched_links