Skip to content

fix(conversation): filter non-group members in SetConversations - #3841

Open
cyper98 wants to merge 1 commit into
openimsdk:mainfrom
cyper98:fix/issue-3827-set-conversations
Open

cyper98 wants to merge 1 commit into
openimsdk:mainfrom
cyper98:fix/issue-3827-set-conversations

Conversation

@cyper98

@cyper98 cyper98 commented Nov 8, 2026

Copy link
Copy Markdown

🅰 Please add the issue ID after "Fixes #"

Fixes #3827

Description

This PR fixes #3827 where SetConversations could insert new conversation documents for non-group members when handling ReadGroupChatType conversations with a group_id.

Root Cause

SetConversations in internal/rpc/conversation/conversation.go did not validate that UserIDs were actually members of the target group (group_member). When passed non-member user IDs, SetUsersConversationFieldTx created ghost session documents (sg_<groupID>) for users who were never in the group.

Solution

  1. Validate req.Conversation != nil and len(req.UserIDs) > 0.
  2. Automatically resolve req.Conversation.GroupID / req.Conversation.ConversationID if one of them is missing.
  3. When ConversationType == constant.ReadGroupChatType and GroupID is present, fetch the current group member IDs via c.groupClient.GetGroupMemberUserIDs(authverify.WithTempAdmin(ctx), req.Conversation.GroupID).
  4. Filter req.UserIDs to the intersection with group members; log a warning for any ignored non-members.
  5. If the filtered list is empty, return success without touching the database.
  6. Added defensive nil checks for conversationNotificationSender.
  7. Added unit test suite in internal/rpc/conversation/conversation_test.go covering all valid, invalid, and edge cases (all tests pass).

@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 8, 2026

This branch has not been deployed

No deployments
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.

SetConversations creates group conversations for non-group members (ReadGroupChatType)

1 participant