Skip to content

fix(group): use admin context when updating member conversations on announcement set - #3840

Open
cyper98 wants to merge 2 commits into
openimsdk:mainfrom
cyper98:fix/group-notification-admin-context
Open

cyper98 wants to merge 2 commits into
openimsdk:mainfrom
cyper98:fix/group-notification-admin-context

Conversation

@cyper98

@cyper98 cyper98 commented Nov 8, 2026

Copy link
Copy Markdown

Related Issue

Fixes: #3830

What does this PR do?

Fixes an issue where updating a group announcement (Notification) in SetGroupInfo and SetGroupInfoEx failed to update conversation flags (GroupAtType = constant.GroupNotification) for group members.

Root Cause

When a group owner/admin (regular user) updates the group announcement:

  1. SetGroupInfo calls conversationClient.SetConversations for all group members (resp.UserIDs).
  2. The conversation RPC service executes authverify.CheckAccess(ctx, userID) for each member ID.
  3. Since the caller context (ctx) belongs to a regular user and not an IM system administrator (IsAdmin(ctx) == false), CheckAccess rejects the request with ErrNoPermission as soon as it evaluates any member other than the caller.
  4. Consequently, member conversations were never updated, and the error was previously swallowed inside a closure.

Solution

  • Created convCtx with g.adminUserIDs[0] (mcontext.WithOpUserIDContext) to escalate privileges for the internal SetConversations RPC call, matching the permission check required by the conversation service.
  • Preserved the original ctx for log.ZWarn to maintain caller audit traceability (opUserID).
  • Propagated errors properly (return nil, err) if SetConversations fails.
  • Added comprehensive unit tests in internal/rpc/group/group_test.go covering admin context propagation and error handling.

How Has This Been Tested?

  • Unit tests added and passed:
    go test -v ./internal/rpc/group/... -run "TestSetGroupInfo"
  • Verified that SetConversations is executed with the administrator context.

@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
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🤖 All Contributors have signed the CLA.
The signed information is recorded here
Posted by the CLA Assistant Lite bot.

@cyper98

cyper98 commented Nov 8, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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

1 participant