Skip to content

feat: add exclude_channel_cids to delete many users - #293

Merged
yaziine merged 1 commit into
mainfrom
feat/cha-6824-exclude-channel-cids
Nov 25, 2026
Merged

yaziine merged 1 commit into
mainfrom
feat/cha-6824-exclude-channel-cids

Conversation

@yaziine

@yaziine yaziine commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Ticket

CHA-6824

Problem

POST /users/delete gained an optional exclude_channel_cids list (GetStream/chat #21218, live on every chat release since v241.18.x). Channels in the list keep the deleted users' messages, memberships, thread participation and reactions, and are not deleted as conversations. It is meant for legal holds. User.deleteMany cannot send it: UserDeleteManyRequestData only has user_ids, user, messages and conversations.

Solution

UserDeleteManyRequest.excludeChannelCids(List<String>) sends exclude_channel_cids in the request body. The field is omitted when unset, so existing calls send the same request as before. DOCS.md gets an example.

The server owns the rules: at most 1000 entries, duplicates included; a 400 with a hard user delete strategy, with files, or for a malformed CID; a well-formed CID that does not exist excludes nothing.

How to verify

  1. ./gradlew test --tests '*UserDeleteManyExcludeChannelsTest*' passes (2 tests, no API credentials needed). They assert the body carries exclude_channel_cids when set and omits it when unset.
  2. ./gradlew spotlessCheck passes.
  3. Checked live against a QA app on a production shard with a throwaway test (not committed): a soft delete with the held channel excluded kept that channel and its message and deleted the user's other 1:1 channel; a second hard delete without the exclusion then deleted the held channel.

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested

🤖 Generated with Claude Code


Note

Medium Risk
Touches user deletion request payloads; wrong usage could leave unexpected data or fail deletes, but the change is additive and backward compatible when the field is unset.

Overview
Adds support for the Chat API’s exclude_channel_cids option on bulk user delete so callers can preserve specific channels (e.g. legal holds) when soft-deleting users.

User.deleteMany now accepts excludeChannelCids(List<String>), which serializes to exclude_channel_cids when set and stays omitted for unchanged requests. Documented limits: at most 1000 CIDs; not valid with a hard user delete strategy (enforced by the API).

DOCS.md includes a new example chaining soft user delete, hard message/conversation delete, and channel exclusion. UserDeleteManyExcludeChannelsTest asserts JSON serialization includes or omits the field without live API calls.

Reviewed by Cursor Bugbot for commit f11a279. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yaziine
yaziine merged commit 232d9da into main Nov 25, 2026
6 checks passed
@yaziine
yaziine deleted the feat/cha-6824-exclude-channel-cids branch November 25, 2026 12:46
@adityaalifn adityaalifn mentioned this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants