Skip to content

Conversation

rookiewwj
Copy link

part of openimsdk/open-im-server#3527

Summary

SDK-side support for group message read receipts: introduce a cursor model, a sync API, and improved notification handling.
Part of openimsdk/open-im-server#3527

Data Model

  • readCursorState: stores the latest per-conversation cursorVersion used as the anchor for incremental sync.
  • ReadCursor: maintains (convID, uid) → maxReadSeq for each user in a conversation.
  • Message.AttachmentInfo.cursorVersion: records the cursorVersion at the last projection/update, enabling idempotency and preventing duplicate projections.

API

  • getConversationReadCursors(): syncs conversation read cursors from the server to local storage; persists (convID, uid, maxReadSeq) and updates local caches/indexes.
  • projectGroupReadInfo(): projects cursor data from the local DB onto Message.AttachmentInfo; recommended to call for messages in the visible viewport.

Notifications

  • Group notifications: enhanced handling of membership/metadata changes and cursor deltas; promptly updates local readCursorState and ReadCursor.
  • Conversation message notifications: added handling for group read-receipt events.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 6, 2025
@OpenIM-Robot
Copy link

⚠️ Non-English comments were found in the following locations:

./internal/group/notification.go:82				// 初始化群读游标状态
./internal/group/notification.go:120					// 自己退群:清空该群会话的所有游标与状态
./internal/group/notification.go:129					// 他人退群:仅删除该成员游标并自增版本
./internal/group/notification.go:165					// 自己被踢:清空该群会话的所有游标与状态
./internal/group/notification.go:174					// 其他成员被踢:仅删除这些成员的游标并自增版本
./internal/group/notification.go:200				// 为所有被邀请的用户创建群读游标 并自增版本
./internal/group/notification.go:231				// 为进入群的用户创建群读游标并自增版本
./internal/group/notification.go:260				// 群解散:清理该会话下所有本地游标与状态
./internal/conversation_msg/read_drawing.go:290							// 如果不存在则创建新的游标
./internal/conversation_msg/read_drawing.go:308						// 如果存在且新序号更大则更新
./internal/conversation_msg/projection.go:14	// projectGroupReadInfo 根据本地存储的群聊已读游标,将指定消息投影计算其 GroupHasReadInfo(HasReadUserIDList/HasReadCount),并回写到消息的 AttachedInfo。
./internal/conversation_msg/projection.go:15	// 入参:conversationID、需要投影的消息 clientMsgID 列表。
./internal/conversation_msg/projection.go:16	// 作用:根据本地的"群聊已读游标表"(convid+uid -> maxReadSeq),对传入的消息做已读投影,
./internal/conversation_msg/projection.go:17	// 回填到消息的 AttachedInfo.GroupHasReadInfo
./internal/conversation_msg/projection.go:18	// 说明:
./internal/conversation_msg/projection.go:19	// - 游标版本是"这批投影基于哪一版游标集计算出来的"标记,用于避免重复回填;
./internal/conversation_msg/projection.go:20	// - 建议仅对"可视区"调用此函数。
./internal/conversation_msg/sync.go:145		// 1. 获取所有群聊会话ID
./internal/conversation_msg/sync.go:166		// 2. 为每个群会话确保初始化 CursorState(如不存在则创建)
./internal/conversation_msg/sync.go:177		// 3. 调用服务器API获取已读游标
./internal/conversation_msg/sync.go:186		// 4. 处理响应并存储到本地数据库
./internal/conversation_msg/sync.go:202				// 检查是否已存在,如果存在则更新,否则插入

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants