Include `ephemeral` flag in individual messages
This commit is contained in:
parent
c84d96abee
commit
70ce6eff9e
|
@ -403,6 +403,7 @@ public class MessageController {
|
||||||
source.map(account -> account.getAuthenticatedDevice().getId()).orElse(null),
|
source.map(account -> account.getAuthenticatedDevice().getId()).orElse(null),
|
||||||
messages.timestamp() == 0 ? System.currentTimeMillis() : messages.timestamp(),
|
messages.timestamp() == 0 ? System.currentTimeMillis() : messages.timestamp(),
|
||||||
isStory,
|
isStory,
|
||||||
|
messages.online(),
|
||||||
messages.urgent(),
|
messages.urgent(),
|
||||||
reportSpamToken.orElse(null));
|
reportSpamToken.orElse(null));
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ public record IncomingMessage(int type, byte destinationDeviceId, int destinatio
|
||||||
@Nullable Byte sourceDeviceId,
|
@Nullable Byte sourceDeviceId,
|
||||||
final long timestamp,
|
final long timestamp,
|
||||||
final boolean story,
|
final boolean story,
|
||||||
|
final boolean ephemeral,
|
||||||
final boolean urgent,
|
final boolean urgent,
|
||||||
@Nullable byte[] reportSpamToken) {
|
@Nullable byte[] reportSpamToken) {
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ public record IncomingMessage(int type, byte destinationDeviceId, int destinatio
|
||||||
.setServerTimestamp(System.currentTimeMillis())
|
.setServerTimestamp(System.currentTimeMillis())
|
||||||
.setDestinationServiceId(destinationIdentifier.toServiceIdentifierString())
|
.setDestinationServiceId(destinationIdentifier.toServiceIdentifierString())
|
||||||
.setStory(story)
|
.setStory(story)
|
||||||
|
.setEphemeral(ephemeral)
|
||||||
.setUrgent(urgent);
|
.setUrgent(urgent);
|
||||||
|
|
||||||
if (sourceAccount != null && sourceDeviceId != null) {
|
if (sourceAccount != null && sourceDeviceId != null) {
|
||||||
|
|
|
@ -64,8 +64,6 @@ class OutgoingMessageEntityTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void entityPreservesEnvelope() {
|
void entityPreservesEnvelope() {
|
||||||
final Random random = new Random();
|
|
||||||
|
|
||||||
final byte[] reportSpamToken = TestRandomUtil.nextBytes(8);
|
final byte[] reportSpamToken = TestRandomUtil.nextBytes(8);
|
||||||
|
|
||||||
final Account account = new Account();
|
final Account account = new Account();
|
||||||
|
@ -79,11 +77,14 @@ class OutgoingMessageEntityTest {
|
||||||
(byte) 123,
|
(byte) 123,
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
true,
|
true,
|
||||||
reportSpamToken);
|
reportSpamToken);
|
||||||
|
|
||||||
MessageProtos.Envelope envelope = baseEnvelope.toBuilder().setServerGuid(UUID.randomUUID().toString()).build();
|
MessageProtos.Envelope envelope = baseEnvelope.toBuilder().setServerGuid(UUID.randomUUID().toString()).build();
|
||||||
|
|
||||||
assertEquals(envelope, OutgoingMessageEntity.fromEnvelope(envelope).toEnvelope());
|
// Note that outgoing message entities don't have an "ephemeral"/"online" flag
|
||||||
|
assertEquals(envelope.toBuilder().clearEphemeral().build(),
|
||||||
|
OutgoingMessageEntity.fromEnvelope(envelope).toEnvelope());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue