Skip to content

Commit aae5ea5

Browse files
committed
chore: add activity copy limit to follow
1 parent 7f8c7f5 commit aae5ea5

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/main/java/io/getstream/core/models/FollowRelation.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package io.getstream.core.models;
22

3+
import static com.google.common.base.Preconditions.checkArgument;
34
import static com.google.common.base.Preconditions.checkNotNull;
45

56
import com.fasterxml.jackson.annotation.JsonCreator;
67
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonInclude;
79
import com.fasterxml.jackson.annotation.JsonProperty;
810
import com.google.common.base.MoreObjects;
911
import java.util.Objects;
@@ -12,15 +14,26 @@
1214
public final class FollowRelation {
1315
private final String source;
1416
private final String target;
17+
private final Integer activityCopyLimit;
1518

1619
@JsonCreator
1720
public FollowRelation(
18-
@JsonProperty("feed_id") String source, @JsonProperty("target_id") String target) {
21+
@JsonProperty("feed_id") String source,
22+
@JsonProperty("target_id") String target,
23+
@JsonProperty("activity_copy_limit") Integer activityCopyLimit) {
1924
checkNotNull(source, "FollowRelation 'source' field required");
2025
checkNotNull(target, "FollowRelation 'target' field required");
26+
if (activityCopyLimit != null) {
27+
checkArgument(activityCopyLimit >= 0, "Activity copy limit must be non negative");
28+
}
2129

2230
this.source = source;
2331
this.target = target;
32+
this.activityCopyLimit = activityCopyLimit;
33+
}
34+
35+
public FollowRelation(String source, String target) {
36+
this(source, target, null);
2437
}
2538

2639
public String getSource() {
@@ -31,24 +44,33 @@ public String getTarget() {
3144
return this.target;
3245
}
3346

47+
@JsonProperty("activity_copy_limit")
48+
@JsonInclude(JsonInclude.Include.NON_NULL)
49+
public Integer getActivityCopyLimit() {
50+
return this.activityCopyLimit;
51+
}
52+
3453
@Override
3554
public boolean equals(Object o) {
3655
if (this == o) return true;
3756
if (o == null || getClass() != o.getClass()) return false;
3857
FollowRelation that = (FollowRelation) o;
39-
return Objects.equals(source, that.source) && Objects.equals(target, that.target);
58+
return Objects.equals(source, that.source)
59+
&& Objects.equals(target, that.target)
60+
&& Objects.equals(activityCopyLimit, that.activityCopyLimit);
4061
}
4162

4263
@Override
4364
public int hashCode() {
44-
return Objects.hash(source, target);
65+
return Objects.hash(source, target, activityCopyLimit);
4566
}
4667

4768
@Override
4869
public String toString() {
4970
return MoreObjects.toStringHelper(this)
5071
.add("source", this.source)
5172
.add("target", this.target)
73+
.add("activityCopyLimit", this.activityCopyLimit)
5274
.toString();
5375
}
5476
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ public void followMany() throws Exception {
4444
client.followMany(follows.toArray(new FollowRelation[0])).join();
4545
}
4646

47+
@Test
48+
public void followManyWithPerRelationActivityCopyLimit() throws Exception {
49+
BatchClient client = Client.builder(apiKey, secret).build().batch();
50+
// Test per-relationship activity_copy_limit
51+
client
52+
.followMany(
53+
new FollowRelation[] {
54+
new FollowRelation("flat:1", "flat:2", 10),
55+
new FollowRelation("aggregated:1", "flat:1", 20)
56+
})
57+
.join();
58+
}
59+
4760
@Test
4861
public void unfollowMany() throws Exception {
4962
BatchClient client = Client.builder(apiKey, secret).build().batch();

0 commit comments

Comments
 (0)