fix: send SyncStatus/ackDiff after processing buyer messages to clear unread indicators#91
Open
octo-patch wants to merge 1 commit into
Open
fix: send SyncStatus/ackDiff after processing buyer messages to clear unread indicators#91octo-patch wants to merge 1 commit into
octo-patch wants to merge 1 commit into
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ackmethod that sends aSyncStatus/ackDiffWebSocket message to the server after processing each buyer message. This follows the same protocol used ininit()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 tocreate_time * 1000(converting the message timestamp from milliseconds to microseconds) if the sync package does not include aptsfield.send_read_ackis called in two places:bot_reply == "-") — the message is still "seen" by the bot and should be marked as readTesting
init().