|
1 | 1 | package io.getstream.client; |
2 | 2 |
|
3 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
| 3 | +import static io.getstream.core.utils.Auth.buildReactionsToken; |
| 4 | +import static io.getstream.core.utils.Routes.*; |
| 5 | +import static io.getstream.core.utils.Serialization.*; |
| 6 | + |
4 | 7 | import io.getstream.core.Moderation; |
5 | | -import io.getstream.core.StreamBatch; |
6 | 8 | import io.getstream.core.exceptions.StreamException; |
7 | | -import io.getstream.core.http.HTTPClient; |
| 9 | +import io.getstream.core.http.Response; |
8 | 10 | import io.getstream.core.http.Token; |
9 | 11 | import io.getstream.core.utils.Auth; |
10 | | -import java8.util.concurrent.CompletableFuture; |
11 | | -import java8.util.concurrent.CompletionException; |
12 | | -import io.getstream.core.http.Response; |
13 | | - |
14 | | -import java.net.MalformedURLException; |
15 | | -import java.net.URISyntaxException; |
16 | | -import java.net.URL; |
17 | | -import java.util.Arrays; |
18 | 12 | import java.util.Map; |
19 | | - |
20 | | -import static io.getstream.core.utils.Auth.buildReactionsToken; |
21 | | -import static io.getstream.core.utils.Routes.*; |
22 | | - |
23 | | -import java.io.IOException; |
24 | | - |
25 | | -import static com.google.common.base.Preconditions.checkArgument; |
26 | | -import static com.google.common.base.Preconditions.checkNotNull; |
27 | | -import static io.getstream.core.utils.Request.buildPost; |
28 | | -import static io.getstream.core.utils.Serialization.*; |
| 13 | +import java8.util.concurrent.CompletableFuture; |
29 | 14 |
|
30 | 15 | public class ModerationClient { |
31 | | - private final String secret; |
32 | | - private final Moderation mod; |
33 | | - |
34 | | - ModerationClient(String secret, Moderation mod) { |
35 | | - this.secret = secret; |
36 | | - this.mod = mod; |
37 | | - } |
38 | | - |
39 | | - public CompletableFuture<Response> flagUser(String flaggedUserId, String reason, Map<String, Object> options)throws StreamException { |
40 | | - return flag("stream:user", flaggedUserId, "", reason, options); |
41 | | - } |
42 | | - |
43 | | - public CompletableFuture<Response> flagActivity(String entityId, String entityCreatorId, String reason, Map<String, Object> options) throws StreamException{ |
44 | | - return flag("stream:feeds:v2:activity", entityId, entityCreatorId, reason, options); |
45 | | - } |
46 | | - |
47 | | - public CompletableFuture<Response> flagReaction(String entityId, String entityCreatorId, String reason, Map<String, Object> options) throws StreamException{ |
48 | | - return flag("stream:feeds:v2:reaction", entityId, entityCreatorId, reason, options); |
49 | | - } |
50 | | - |
51 | | - private CompletableFuture<Response> flag(String entityType, String entityId, String entityCreatorId, |
52 | | - String reason, Map<String, Object> options)throws StreamException { |
53 | | - final Token token = buildReactionsToken(secret, Auth.TokenAction.WRITE); |
54 | | - return mod.flag(token, entityType, entityId, entityCreatorId, reason, options); |
55 | | - } |
| 16 | + private final String secret; |
| 17 | + private final Moderation mod; |
| 18 | + |
| 19 | + ModerationClient(String secret, Moderation mod) { |
| 20 | + this.secret = secret; |
| 21 | + this.mod = mod; |
| 22 | + } |
| 23 | + |
| 24 | + public CompletableFuture<Response> flagUser( |
| 25 | + String flaggedUserId, String reason, Map<String, Object> options) throws StreamException { |
| 26 | + return flag("stream:user", flaggedUserId, "", reason, options); |
| 27 | + } |
| 28 | + |
| 29 | + public CompletableFuture<Response> flagActivity( |
| 30 | + String entityId, String entityCreatorId, String reason, Map<String, Object> options) |
| 31 | + throws StreamException { |
| 32 | + return flag("stream:feeds:v2:activity", entityId, entityCreatorId, reason, options); |
| 33 | + } |
| 34 | + |
| 35 | + public CompletableFuture<Response> flagReaction( |
| 36 | + String entityId, String entityCreatorId, String reason, Map<String, Object> options) |
| 37 | + throws StreamException { |
| 38 | + return flag("stream:feeds:v2:reaction", entityId, entityCreatorId, reason, options); |
| 39 | + } |
| 40 | + |
| 41 | + private CompletableFuture<Response> flag( |
| 42 | + String entityType, |
| 43 | + String entityId, |
| 44 | + String entityCreatorId, |
| 45 | + String reason, |
| 46 | + Map<String, Object> options) |
| 47 | + throws StreamException { |
| 48 | + final Token token = buildReactionsToken(secret, Auth.TokenAction.WRITE); |
| 49 | + return mod.flag(token, entityType, entityId, entityCreatorId, reason, options); |
| 50 | + } |
56 | 51 | } |
0 commit comments