Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,24 @@ var taskId = ExportUsers.exportUsers(List.of("u1", "u2"))
.request().getTaskId();
```

**Export sent and received messages, with IDs redacted**

`direction("sent_and_received")` also exports each of the user's channels, followed by the
messages other users sent there in the message window. `redactIds(true)` replaces other users'
IDs and channel IDs with placeholders derived from `redactSalt`; the exported user's own ID is
kept. Both require exactly one user ID. `excludeSoftDeletedMessages` and
`excludeSoftDeletedChannels` leave soft-deleted data out (both default to false).

```java
var taskId = ExportUsers.exportUsers(List.of("u1"))
.direction("sent_and_received")
.redactIds(true)
.redactSalt("my-secret-salt")
.excludeSoftDeletedMessages(false)
.excludeSoftDeletedChannels(false)
.request().getTaskId();
```

**Deactivate user**

```java
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/io/getstream/chat/java/models/ExportUsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,53 @@ public static class ExportUsersRequestData {
@JsonInclude(Include.NON_NULL)
private Date messagesTo;

/**
* Replace other users' IDs and channel IDs in the export file with deterministic placeholders
* (user-<hash>, conversation-<hash>) derived from redactSalt. The exported user's
* own ID is kept. Requires redactSalt and exactly one entry in userIds.
*/
@Nullable
@JsonProperty("redact_ids")
@JsonInclude(Include.NON_NULL)
private Boolean redactIds;

/**
* Secret used to derive the redaction placeholders (at most 255 characters). Required with
* redactIds and rejected without it.
*/
@Nullable
@JsonProperty("redact_salt")
@JsonInclude(Include.NON_NULL)
private String redactSalt;

/**
* Which messages to export: "sent" (the default) or "sent_and_received". "sent_and_received"
* also exports each of the user's channels, followed by the messages other users sent there in
* the message window. It requires exactly one entry in userIds.
*/
@Nullable
@JsonProperty("direction")
@JsonInclude(Include.NON_NULL)
private String direction;

/**
* Leave soft-deleted messages out of the export, in both directions, the user's own messages
* included. Defaults to false.
*/
@Nullable
@JsonProperty("exclude_soft_deleted_messages")
@JsonInclude(Include.NON_NULL)
private Boolean excludeSoftDeletedMessages;

/**
* Leave soft-deleted channels out of the export, in both directions. Defaults to false. Note
* that the channel export API uses include_soft_deleted_channels, with the opposite default.
*/
@Nullable
@JsonProperty("exclude_soft_deleted_channels")
@JsonInclude(Include.NON_NULL)
private Boolean excludeSoftDeletedChannels;

public static class ExportUsersRequest extends StreamRequest<ExportUsers.ExportUsersResponse> {
@Override
protected Call<ExportUsers.ExportUsersResponse> generateCall(Client client) {
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/io/getstream/chat/java/ExportUsersFiltersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ void whenFiltersSet_thenBodyCarriesThem() throws Exception {
Assertions.assertTrue(json.contains("\"messages_to\":\"2026-07-01T00:00:00.000+00:00\""), json);
}

@DisplayName("Export users sends redaction, direction and soft-delete exclusions when set")
@Test
void whenRedactionAndDirectionSet_thenBodyCarriesThem() throws Exception {
String json =
body(
ExportUsers.exportUsers(Arrays.asList("user-1"))
.redactIds(true)
.redactSalt("salt-1")
.direction("sent_and_received")
.excludeSoftDeletedMessages(true)
.excludeSoftDeletedChannels(false));

Assertions.assertTrue(json.contains("\"redact_ids\":true"), json);
Assertions.assertTrue(json.contains("\"redact_salt\":\"salt-1\""), json);
Assertions.assertTrue(json.contains("\"direction\":\"sent_and_received\""), json);
Assertions.assertTrue(json.contains("\"exclude_soft_deleted_messages\":true"), json);
Assertions.assertTrue(json.contains("\"exclude_soft_deleted_channels\":false"), json);
}

@DisplayName("Export users omits the filters when unset")
@Test
void whenFiltersUnset_thenBodyOmitsThem() throws Exception {
Expand Down
Loading