Minor cleanup of report spam endpoint (#1979)
This commit is contained in:
parent
e7d1eadf8e
commit
7f0f045f29
|
@ -752,7 +752,7 @@ public class MessageController {
|
|||
@ReadOnly @Auth AuthenticatedAccount auth,
|
||||
@PathParam("source") String source,
|
||||
@PathParam("messageGuid") UUID messageGuid,
|
||||
@Nullable @Valid SpamReport spamReport,
|
||||
@Nullable SpamReport spamReport,
|
||||
@HeaderParam(HttpHeaders.USER_AGENT) String userAgent
|
||||
) {
|
||||
|
||||
|
@ -786,7 +786,7 @@ public class MessageController {
|
|||
|
||||
UUID spamReporterUuid = auth.getAccount().getUuid();
|
||||
|
||||
// spam report token is optional, but if provided ensure it is valid base64 and non-empty.
|
||||
// spam report token is optional, but if provided ensure it is non-empty.
|
||||
final Optional<byte[]> maybeSpamReportToken =
|
||||
Optional.ofNullable(spamReport)
|
||||
.flatMap(r -> Optional.ofNullable(r.token()))
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package org.whispersystems.textsecuregcm.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.whispersystems.textsecuregcm.util.ByteArrayAdapter;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import org.whispersystems.textsecuregcm.util.ByteArrayAdapter;
|
||||
|
||||
public record SpamReport(@JsonSerialize(using = ByteArrayAdapter.Serializing.class)
|
||||
@JsonDeserialize(using = ByteArrayAdapter.Deserializing.class)
|
||||
|
|
|
@ -904,7 +904,8 @@ class MessageControllerTest {
|
|||
Arguments.of(Entity.json("null"), true),
|
||||
Arguments.of(Entity.json("{\"weird\": 123}"), true),
|
||||
Arguments.of(Entity.json("\"weirder\""), false),
|
||||
Arguments.of(Entity.json("weirdest"), false)
|
||||
Arguments.of(Entity.json("weirdest"), false),
|
||||
Arguments.of(Entity.json("{\"token\":\"InvalidBase64[][][][]\"}"), false)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue