Skip to content

fix(lark): don't replay pre-authorization messages as chats#603

Open
loind wants to merge 1 commit into
iOfficeAI:mainfrom
loind:fix/lark-pairing-stale-message
Open

fix(lark): don't replay pre-authorization messages as chats#603
loind wants to merge 1 commit into
iOfficeAI:mainfrom
loind:fix/lark-pairing-stale-message

Conversation

@loind

@loind loind commented Jul 11, 2026

Copy link
Copy Markdown

Summary

A message a user sends before being authorized only serves to hand out a pairing code — it must never be dispatched to the agent. If the platform redelivers that message (e.g. after a WebSocket reconnect), it was being replayed as a real chat message and the bot auto-replied (observed: a "hi" used to pair produced an unsolicited "Hello!" on Lark after approval).

Fix

  • handle_incoming_message: drop messages whose timestamp predates the user's authorized_at (unix seconds vs millis). Pairing-era / redelivered messages no longer become chats; genuinely new messages (sent after approval) are unaffected.
  • Add MessageResult::Ignored no-op variant for that path (handled in orchestrator.rs).
  • PairingService::get_authorized_user returns (id, authorized_at) in one lookup.

Testing

  • New unit test action::tests::message_before_authorization_is_ignored.
  • cargo test -p aionui-channel — all green.

Notes

Platform-agnostic (applies to all channels). Independent of the Lark region work (#602).

A message sent before a user is authorized only serves to hand out a
pairing code; it must never be dispatched to the agent. If the platform
redelivers that message (e.g. after a reconnect), it was being replayed
as a real chat message and the bot auto-replied ("hi" → "Hello!").

Drop messages whose timestamp predates the user's authorized_at, and add
a MessageResult::Ignored no-op variant for that path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant