Skip to content

fix: send SyncStatus/ackDiff after processing buyer messages to clear unread indicators#91

Open
octo-patch wants to merge 1 commit into
shaxiu:mainfrom
octo-patch:fix/issue-89-send-read-ack
Open

fix: send SyncStatus/ackDiff after processing buyer messages to clear unread indicators#91
octo-patch wants to merge 1 commit into
shaxiu:mainfrom
octo-patch:fix/issue-89-send-read-ack

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #89

Problem

When the bot receives a message from a buyer and sends an auto-reply, it was not sending a read acknowledgment (SyncStatus/ackDiff) back to the Xianyu server. As a result, the seller's Xianyu interface continued to show those buyer messages as unread, even though the bot had already processed and replied to them. This creates a confusing experience where the seller sees a non-zero unread count despite the bot handling all messages.

Solution

Add a send_read_ack method that sends a SyncStatus/ackDiff WebSocket message to the server after processing each buyer message. This follows the same protocol used in init() to acknowledge sync state.

The pts (point-in-time state) value is extracted from the incoming sync package (sync_data.get("pts", ...)), with a fallback to create_time * 1000 (converting the message timestamp from milliseconds to microseconds) if the sync package does not include a pts field.

send_read_ack is called in two places:

  1. After sending an auto-reply to the buyer
  2. When the bot decides not to reply (bot_reply == "-") — the message is still "seen" by the bot and should be marked as read

Testing

  • The fix is additive: it sends an additional WebSocket message that mirrors the sync ack already sent during init().
  • Error handling wraps the send so that a failure to send the ack does not interrupt message processing.
  • No new dependencies or schema changes introduced.

… unread indicators (fixes shaxiu#89)

When the bot processes and replies to buyer messages, it was not sending
a read acknowledgment (SyncStatus/ackDiff) back to the server. This caused
the seller's Xianyu interface to continue showing those messages as unread,
even though the bot had already replied to them.

Add a send_read_ack method that sends an ackDiff sync acknowledgment
using the message's pts timestamp (extracted from the sync package, with
a fallback to the message creation time). This is called after:
- Sending an auto-reply to the buyer
- Skipping a reply -- the message is still seen by the bot
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