fix(telegram): dedupe candidates before sending

Deduplicate candidates by aid at the notifier boundary so duplicate queue entries cannot produce repeated message bodies and button rows. The discovery layer already deduped by aid; this adds defense in depth with a regression test.
This commit is contained in:
kairee committed 2026-10-31 21:55:10 +08:00
1 parent d971e718e9
commit e2e4dc3336
2 files changed
+22 -1

No files matched your search

+9 -1
View File
@@ -98,7 +98,15 @@ class TelegramClient:
return self._call("sendMessage", params)
def send_candidates(self, candidates: Sequence[Mapping[str, Any]]) -> bool:
items = list(candidates)
# 通知器边界再做一次 aid 去重,避免调用方重复入队导致消息主体和按钮重复。
items: list[Mapping[str, Any]] = []
seen: set[int] = set()
for candidate in candidates:
aid = candidate.get("aid")
if aid in seen:
continue
seen.add(aid)
items.append(candidate)
if not items:
return True
for index in range(0, len(items), MAX_CANDIDATES_PER_MESSAGE):