Skip to content

Commit b7d01bc

Browse files
committed
chore: discard_actors
1 parent 90de6fa commit b7d01bc

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

src/main/java/io/getstream/client/FlatFeed.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@ limit, offset, filter, DefaultOptions.DEFAULT_MARKER, new Ranking(ranking), rank
127127
});
128128
}
129129

130+
public CompletableFuture<List<Activity>> getActivities(RequestOption... options)
131+
throws StreamException {
132+
// If no options provided, use defaults
133+
if (options == null || options.length == 0) {
134+
options = new RequestOption[] {
135+
DefaultOptions.DEFAULT_LIMIT,
136+
DefaultOptions.DEFAULT_OFFSET,
137+
DefaultOptions.DEFAULT_FILTER,
138+
DefaultOptions.DEFAULT_MARKER
139+
};
140+
}
141+
142+
return getClient()
143+
.getActivities(getID(), options)
144+
.thenApply(
145+
response -> {
146+
try {
147+
return deserializeContainer(response, Activity.class);
148+
} catch (StreamException | IOException e) {
149+
throw new CompletionException(e);
150+
}
151+
});
152+
}
130153

131154
public <T> CompletableFuture<List<T>> getCustomActivities(Class<T> type) throws StreamException {
132155
return getCustomActivities(
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package io.getstream.core.options;
2+
3+
import static com.google.common.base.Preconditions.checkNotNull;
4+
5+
import io.getstream.core.http.Request;
6+
import java.util.List;
7+
8+
public final class DiscardActors implements RequestOption {
9+
private final String actors;
10+
private final String separator;
11+
12+
public DiscardActors(String... actors) {
13+
this(actors, ",");
14+
}
15+
16+
public DiscardActors(List<String> actors) {
17+
this(actors, ",");
18+
}
19+
20+
public DiscardActors(String[] actors, String separator) {
21+
checkNotNull(actors, "Actors list cannot be null");
22+
this.actors = String.join(separator != null ? separator : ",", actors);
23+
this.separator = separator;
24+
}
25+
26+
public DiscardActors(List<String> actors, String separator) {
27+
checkNotNull(actors, "Actors list cannot be null");
28+
this.actors = String.join(separator != null ? separator : ",", actors);
29+
this.separator = separator;
30+
}
31+
32+
@Override
33+
public void apply(Request.Builder builder) {
34+
if (actors != null && !actors.isEmpty()) {
35+
builder.addQueryParameter("discard_actors", actors);
36+
if (separator != null && !separator.equals(",")) {
37+
builder.addQueryParameter("discard_actors_sep", separator);
38+
}
39+
}
40+
}
41+
}

src/test/java/io/getstream/client/FlatFeedTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.getstream.core.models.Activity;
88
import io.getstream.core.models.Data;
99
import io.getstream.core.models.EnrichedActivity;
10+
import io.getstream.core.options.DiscardActors;
1011
import io.getstream.core.options.EnrichmentFlags;
1112
import java.util.Collections;
1213
import java.util.List;
@@ -101,6 +102,29 @@ public void invalidFeedType() throws Exception {
101102
.build();
102103

103104
FlatFeed feed = client.flatFeed("aggregated", "1");
104-
List<Activity> result = feed.getActivities().join();
105+
feed.getActivities().join();
106+
}
107+
108+
109+
@Test
110+
public void testDiscardActorsOptions() {
111+
// Test DiscardActors with array
112+
DiscardActors discardActors1 = new DiscardActors("user1", "user2", "user3");
113+
114+
// Test DiscardActors with List
115+
List<String> actors = java.util.Arrays.asList("user4", "user5");
116+
DiscardActors discardActors2 = new DiscardActors(actors);
117+
118+
// Test DiscardActors with custom separator
119+
DiscardActors discardActors3 = new DiscardActors(new String[]{"user6", "user7"}, ";");
120+
121+
// Test DiscardActors with List and custom separator
122+
DiscardActors discardActors4 = new DiscardActors(actors, "|");
123+
124+
// Basic validation that objects were created
125+
assert discardActors1 != null;
126+
assert discardActors2 != null;
127+
assert discardActors3 != null;
128+
assert discardActors4 != null;
105129
}
106130
}

0 commit comments

Comments
 (0)