openimsdk / openim-sdk-core

Instant Messaging
https://openim.io
Apache License 2.0
348 stars 314 forks source link

[BUG] About the bug that the number of unread messages cannot be cleared #556

Closed skywangch closed 1 week ago

skywangch commented 3 months ago

OpenIM Server Version

3.7.1

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

The root of the issue is a bug in the mini-program side when calling OIMWS, but after reviewing the code, the core implementation was found in openim-sdk-core. The number of unread messages is displayed incorrectly, and even after successfully making a call to set the conversation as read, the message count does not reset and remains unchanged. Upon investigating the code at openim-sdk-core/v3@v3.5.1/internal/conversation_msg/read_drawing.go: 142, it was discovered that the unread message list is retrieved first, and then the message count table is cleared. However, if the unread message list is empty, it directly returns, and at this time, the count table might still be greater than zero (due to some inconsistencies). Unless a new unread message is received, the code to clear the count table is unreachable, and the count can never be reset to zero.

Suggestion: Execute the subsequent code regardless of whether the SQLite message table's unread messages are empty or not; do not return prematurely.

Screenshots Link

相关代码:

765e67d55aa54e8c5ff6674c24f2ec9

前端调用 markConversationMessageAsRead, 服务端 oimws 产生的日志:

0b132ca5f55b4c28e4fe9421a020a65

local db 消息表: image

local db 会话表: image

skiffer-git commented 2 months ago

The OIMWS will be phased out, and a new JavaScript SDK is currently under development. This upcoming SDK promises more advanced features and improved performance