Adjust routing for stories.

This commit is contained in:
erik-signal 2022-10-05 12:20:42 -04:00 committed by GitHub
parent 966c3a8f47
commit 544e4fb89a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View File

@ -165,11 +165,10 @@ public class MessageController {
@HeaderParam("User-Agent") String userAgent,
@HeaderParam("X-Forwarded-For") String forwardedFor,
@PathParam("destination") UUID destinationUuid,
@QueryParam("story") boolean isStory,
@NotNull @Valid IncomingMessageList messages)
throws RateLimitExceededException {
boolean isStory = messages.story();
if (source.isEmpty() && accessKey.isEmpty() && !isStory) {
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
}

View File

@ -11,15 +11,14 @@ import javax.validation.Valid;
import javax.validation.constraints.NotNull;
public record IncomingMessageList(@NotNull @Valid List<@NotNull IncomingMessage> messages,
boolean online, boolean urgent, boolean story, long timestamp) {
boolean online, boolean urgent, long timestamp) {
@JsonCreator
public IncomingMessageList(@JsonProperty("messages") @NotNull @Valid List<@NotNull IncomingMessage> messages,
@JsonProperty("online") boolean online,
@JsonProperty("urgent") Boolean urgent,
@JsonProperty("story") Boolean story,
@JsonProperty("timestamp") long timestamp) {
this(messages, online, urgent == null || urgent, story != null && story, timestamp);
this(messages, online, urgent == null || urgent, timestamp);
}
}

View File

@ -676,7 +676,7 @@ class MessageControllerTest {
.request()
.header(OptionalAccess.UNIDENTIFIED, Base64.getEncoder().encodeToString(UNIDENTIFIED_ACCESS_BYTES))
.put(Entity.entity(new IncomingMessageList(
List.of(new IncomingMessage(1, 1L, 1, new String(contentBytes))), false, true, false,
List.of(new IncomingMessage(1, 1L, 1, new String(contentBytes))), false, true,
System.currentTimeMillis()),
MediaType.APPLICATION_JSON_TYPE));