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:
1 parent
d971e718e9
commit
e2e4dc3336
2 files changed
+22
-1
No files matched your search
@@ -67,6 +67,18 @@ def test_send_candidates_and_chunking():
|
||||
assert len(json.loads(transport.calls[1]["data"]["reply_markup"])["inline_keyboard"]) == 1
|
||||
|
||||
|
||||
def test_send_candidates_dedupes_by_aid():
|
||||
transport = FakeTransport()
|
||||
bot = TelegramClient("token", 42, transport=transport)
|
||||
bot.send_candidates([candidate(1), candidate(1), candidate(2)])
|
||||
assert len(transport.calls) == 1
|
||||
keyboard = json.loads(transport.calls[0]["data"]["reply_markup"])
|
||||
assert len(keyboard["inline_keyboard"]) == 2
|
||||
assert [row[0]["callback_data"] for row in keyboard["inline_keyboard"]] == [
|
||||
"fav:1", "fav:2",
|
||||
]
|
||||
|
||||
|
||||
def test_get_updates_and_answer():
|
||||
transport = FakeTransport(result=[])
|
||||
bot = TelegramClient("token", 42, transport=transport, poll_timeout=17)
|
||||
@@ -147,6 +159,7 @@ def test_poller_dispatch_and_authorization():
|
||||
def main():
|
||||
test_format_duration()
|
||||
test_send_candidates_and_chunking()
|
||||
test_send_candidates_dedupes_by_aid()
|
||||
test_get_updates_and_answer()
|
||||
test_poller_dispatch_and_authorization()
|
||||
print("OK: Telegram 消息、分片、长轮询与回调授权测试全部通过")
|
||||
|
||||
Reference in new issue
Block a user