Remove temporary adaptation for nested `IncomingMessage.online`

This commit is contained in:
Chris Eager 2021-05-21 17:05:22 -05:00 committed by Chris Eager
parent c3f53c4dd9
commit 215621a9b0
7 changed files with 2 additions and 93 deletions

View File

@ -298,17 +298,8 @@ public class MessageController {
validateCompleteDeviceList(destination.get(), messages.getMessages(), isSyncMessage);
validateRegistrationIds(destination.get(), messages.getMessages());
// iOS versions prior to 5.5.0.7 send `online` on IncomingMessageList.message, rather on the top-level entity.
// This causes some odd client behaviors, such as persisted typing indicators, so we have a temporary
// server-side adaptation.
final boolean online = messages.getMessages()
.stream()
.findFirst()
.map(IncomingMessage::isOnline)
.orElse(messages.isOnline());
final List<Tag> tags = List.of(UserAgentTagUtil.getPlatformTag(userAgent),
Tag.of(EPHEMERAL_TAG_NAME, String.valueOf(online)),
Tag.of(EPHEMERAL_TAG_NAME, String.valueOf(messages.isOnline())),
Tag.of(SENDER_TYPE_TAG_NAME, senderType));
for (IncomingMessage incomingMessage : messages.getMessages()) {
@ -316,7 +307,7 @@ public class MessageController {
if (destinationDevice.isPresent()) {
Metrics.counter(SENT_MESSAGE_COUNTER_NAME, tags).increment();
sendMessage(source, destination.get(), destinationDevice.get(), messages.getTimestamp(), online, incomingMessage);
sendMessage(source, destination.get(), destinationDevice.get(), messages.getTimestamp(), messages.isOnline(), incomingMessage);
}
}

View File

@ -32,9 +32,6 @@ public class IncomingMessage {
@JsonProperty
private long timestamp; // deprecated
@JsonProperty
private Boolean online; // use IncomingMessageList.online - this is a temporary adaptation for older clients
public String getDestination() {
return destination;
}
@ -62,8 +59,4 @@ public class IncomingMessage {
public String getContent() {
return content;
}
public Boolean isOnline() {
return online;
}
}

View File

@ -583,37 +583,6 @@ class MessageControllerTest {
}
@ParameterizedTest
@MethodSource
void testOnlineMessage(final String fixture, final boolean expectedOnline) throws Exception {
final Response response =
resources.getJerseyTest()
.target(String.format("/v1/messages/%s", SINGLE_DEVICE_RECIPIENT))
.request()
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
.put(Entity.entity(mapper.readValue(jsonFixture(fixture), IncomingMessageList.class),
MediaType.APPLICATION_JSON_TYPE));
assertThat("Good Response", response.getStatus(), is(equalTo(200)));
verify(messageSender, times(1)).sendMessage(any(Account.class), any(Device.class), any(Envelope.class), eq(expectedOnline));
}
private static Stream<Arguments> testOnlineMessage() {
return Stream.of(
Arguments.of("fixtures/current_message_single_device.json", false), // default to `false` when absent
Arguments.of("fixtures/online_message_true.json", true),
Arguments.of("fixtures/online_message_false.json", false),
// iOS versions prior to 5.5.0.7 send `online` on IncomingMessageList.message, rather on the top-level entity.
// This causes some odd client behaviors, such as persisted typing indicators, so we have a temporary
// server-side adaptation.
Arguments.of("fixtures/online_message_true_nested_property.json", true),
Arguments.of("fixtures/online_message_false_nested_property.json", false)
);
}
@Test
void testReportMessage() {

View File

@ -1,11 +0,0 @@
{
"online": false,
"messages": [
{
"type": 1,
"destinationDeviceId": 1,
"body": "Zm9vYmFyego",
"timestamp": 1234
}
]
}

View File

@ -1,11 +0,0 @@
{
"messages": [
{
"type": 1,
"destinationDeviceId": 1,
"body": "Zm9vYmFyego",
"timestamp": 1234,
"online": false
}
]
}

View File

@ -1,11 +0,0 @@
{
"online": true,
"messages": [
{
"type": 1,
"destinationDeviceId": 1,
"body": "Zm9vYmFyego",
"timestamp": 1234
}
]
}

View File

@ -1,11 +0,0 @@
{
"messages": [
{
"type": 1,
"destinationDeviceId": 1,
"body": "Zm9vYmFyego",
"timestamp": 1234,
"online": true
}
]
}