mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update libsignal-service-java
This commit is contained in:
parent
597ac9b504
commit
81e36d4f9b
6 changed files with 47 additions and 22 deletions
|
@ -2806,7 +2806,8 @@
|
||||||
{"name":"sourceE164_"},
|
{"name":"sourceE164_"},
|
||||||
{"name":"sourceUuid_"},
|
{"name":"sourceUuid_"},
|
||||||
{"name":"timestamp_"},
|
{"name":"timestamp_"},
|
||||||
{"name":"type_"}
|
{"name":"type_"},
|
||||||
|
{"name":"urgent_"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3052,6 +3053,7 @@
|
||||||
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$SyncMessage$Sent",
|
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$SyncMessage$Sent",
|
||||||
"fields":[
|
"fields":[
|
||||||
{"name":"bitField0_"},
|
{"name":"bitField0_"},
|
||||||
|
{"name":"destinationE164_"},
|
||||||
{"name":"destinationUuid_"},
|
{"name":"destinationUuid_"},
|
||||||
{"name":"expirationStartTimestamp_"},
|
{"name":"expirationStartTimestamp_"},
|
||||||
{"name":"isRecipientUpdate_"},
|
{"name":"isRecipientUpdate_"},
|
||||||
|
|
|
@ -14,7 +14,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_52")
|
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_53")
|
||||||
implementation("com.fasterxml.jackson.core", "jackson-databind", "2.13.3")
|
implementation("com.fasterxml.jackson.core", "jackson-databind", "2.13.3")
|
||||||
implementation("com.google.protobuf", "protobuf-javalite", "3.11.4")
|
implementation("com.google.protobuf", "protobuf-javalite", "3.11.4")
|
||||||
implementation("org.bouncycastle", "bcprov-jdk15on", "1.70")
|
implementation("org.bouncycastle", "bcprov-jdk15on", "1.70")
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class SendHelper {
|
||||||
(messageSender, address, unidentifiedAccess) -> messageSender.sendReceipt(address,
|
(messageSender, address, unidentifiedAccess) -> messageSender.sendReceipt(address,
|
||||||
unidentifiedAccess,
|
unidentifiedAccess,
|
||||||
receiptMessage));
|
receiptMessage));
|
||||||
messageSendLogStore.insertIfPossible(receiptMessage.getWhen(), result, ContentHint.IMPLICIT);
|
messageSendLogStore.insertIfPossible(receiptMessage.getWhen(), result, ContentHint.IMPLICIT, false);
|
||||||
handleSendMessageResult(result);
|
handleSendMessageResult(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,8 @@ public class SendHelper {
|
||||||
unidentifiedAccess,
|
unidentifiedAccess,
|
||||||
ContentHint.IMPLICIT,
|
ContentHint.IMPLICIT,
|
||||||
message,
|
message,
|
||||||
SignalServiceMessageSender.IndividualSendEvents.EMPTY));
|
SignalServiceMessageSender.IndividualSendEvents.EMPTY,
|
||||||
|
false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendRetryReceipt(
|
public SendMessageResult sendRetryReceipt(
|
||||||
|
@ -237,7 +238,8 @@ public class SendHelper {
|
||||||
timestamp,
|
timestamp,
|
||||||
messageSendLogEntry.content(),
|
messageSendLogEntry.content(),
|
||||||
messageSendLogEntry.contentHint(),
|
messageSendLogEntry.contentHint(),
|
||||||
Optional.empty()));
|
Optional.empty(),
|
||||||
|
messageSendLogEntry.urgent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final var groupId = messageSendLogEntry.groupId().get();
|
final var groupId = messageSendLogEntry.groupId().get();
|
||||||
|
@ -266,7 +268,8 @@ public class SendHelper {
|
||||||
timestamp,
|
timestamp,
|
||||||
contentToSend,
|
contentToSend,
|
||||||
messageSendLogEntry.contentHint(),
|
messageSendLogEntry.contentHint(),
|
||||||
Optional.of(group.getGroupId().serialize())));
|
Optional.of(group.getGroupId().serialize()),
|
||||||
|
messageSendLogEntry.urgent()));
|
||||||
|
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess()) {
|
||||||
final var address = context.getRecipientHelper().resolveSignalServiceAddress(recipientId);
|
final var address = context.getRecipientHelper().resolveSignalServiceAddress(recipientId);
|
||||||
|
@ -315,6 +318,7 @@ public class SendHelper {
|
||||||
final var messageSendLogStore = account.getMessageSendLogStore();
|
final var messageSendLogStore = account.getMessageSendLogStore();
|
||||||
final AtomicLong entryId = new AtomicLong(-1);
|
final AtomicLong entryId = new AtomicLong(-1);
|
||||||
|
|
||||||
|
final var urgent = true;
|
||||||
final LegacySenderHandler legacySender = (recipients, unidentifiedAccess, isRecipientUpdate) -> messageSender.sendDataMessage(
|
final LegacySenderHandler legacySender = (recipients, unidentifiedAccess, isRecipientUpdate) -> messageSender.sendDataMessage(
|
||||||
recipients,
|
recipients,
|
||||||
unidentifiedAccess,
|
unidentifiedAccess,
|
||||||
|
@ -328,14 +332,16 @@ public class SendHelper {
|
||||||
if (entryId.get() == -1) {
|
if (entryId.get() == -1) {
|
||||||
final var newId = messageSendLogStore.insertIfPossible(message.getTimestamp(),
|
final var newId = messageSendLogStore.insertIfPossible(message.getTimestamp(),
|
||||||
sendResult,
|
sendResult,
|
||||||
contentHint);
|
contentHint,
|
||||||
|
urgent);
|
||||||
entryId.set(newId);
|
entryId.set(newId);
|
||||||
} else {
|
} else {
|
||||||
messageSendLogStore.addRecipientToExistingEntryIfPossible(entryId.get(), sendResult);
|
messageSendLogStore.addRecipientToExistingEntryIfPossible(entryId.get(), sendResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() -> false);
|
() -> false,
|
||||||
|
urgent);
|
||||||
final SenderKeySenderHandler senderKeySender = (distId, recipients, unidentifiedAccess, isRecipientUpdate) -> {
|
final SenderKeySenderHandler senderKeySender = (distId, recipients, unidentifiedAccess, isRecipientUpdate) -> {
|
||||||
final var res = messageSender.sendGroupDataMessage(distId,
|
final var res = messageSender.sendGroupDataMessage(distId,
|
||||||
recipients,
|
recipients,
|
||||||
|
@ -343,10 +349,14 @@ public class SendHelper {
|
||||||
isRecipientUpdate,
|
isRecipientUpdate,
|
||||||
contentHint,
|
contentHint,
|
||||||
message,
|
message,
|
||||||
SignalServiceMessageSender.SenderKeyGroupEvents.EMPTY);
|
SignalServiceMessageSender.SenderKeyGroupEvents.EMPTY,
|
||||||
|
urgent);
|
||||||
synchronized (entryId) {
|
synchronized (entryId) {
|
||||||
if (entryId.get() == -1) {
|
if (entryId.get() == -1) {
|
||||||
final var newId = messageSendLogStore.insertIfPossible(message.getTimestamp(), res, contentHint);
|
final var newId = messageSendLogStore.insertIfPossible(message.getTimestamp(),
|
||||||
|
res,
|
||||||
|
contentHint,
|
||||||
|
urgent);
|
||||||
entryId.set(newId);
|
entryId.set(newId);
|
||||||
} else {
|
} else {
|
||||||
messageSendLogStore.addRecipientToExistingEntryIfPossible(entryId.get(), res);
|
messageSendLogStore.addRecipientToExistingEntryIfPossible(entryId.get(), res);
|
||||||
|
@ -582,13 +592,15 @@ public class SendHelper {
|
||||||
SignalServiceDataMessage message, RecipientId recipientId
|
SignalServiceDataMessage message, RecipientId recipientId
|
||||||
) {
|
) {
|
||||||
final var messageSendLogStore = account.getMessageSendLogStore();
|
final var messageSendLogStore = account.getMessageSendLogStore();
|
||||||
|
final var urgent = true;
|
||||||
final var result = handleSendMessage(recipientId,
|
final var result = handleSendMessage(recipientId,
|
||||||
(messageSender, address, unidentifiedAccess) -> messageSender.sendDataMessage(address,
|
(messageSender, address, unidentifiedAccess) -> messageSender.sendDataMessage(address,
|
||||||
unidentifiedAccess,
|
unidentifiedAccess,
|
||||||
ContentHint.RESENDABLE,
|
ContentHint.RESENDABLE,
|
||||||
message,
|
message,
|
||||||
SignalServiceMessageSender.IndividualSendEvents.EMPTY));
|
SignalServiceMessageSender.IndividualSendEvents.EMPTY,
|
||||||
messageSendLogStore.insertIfPossible(message.getTimestamp(), result, ContentHint.RESENDABLE);
|
urgent));
|
||||||
|
messageSendLogStore.insertIfPossible(message.getTimestamp(), result, ContentHint.RESENDABLE, urgent);
|
||||||
handleSendMessageResult(result);
|
handleSendMessageResult(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,5 @@ import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public record MessageSendLogEntry(
|
public record MessageSendLogEntry(
|
||||||
Optional<GroupId> groupId, SignalServiceProtos.Content content, ContentHint contentHint
|
Optional<GroupId> groupId, SignalServiceProtos.Content content, ContentHint contentHint, boolean urgent
|
||||||
) {}
|
) {}
|
||||||
|
|
|
@ -117,7 +117,8 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final var contentHint = ContentHint.fromType(resultSet.getInt("content_hint"));
|
final var contentHint = ContentHint.fromType(resultSet.getInt("content_hint"));
|
||||||
return new MessageSendLogEntry(groupId, content, contentHint);
|
final var urgent = true; // TODO
|
||||||
|
return new MessageSendLogEntry(groupId, content, contentHint, urgent);
|
||||||
})) {
|
})) {
|
||||||
return result.filter(Objects::nonNull)
|
return result.filter(Objects::nonNull)
|
||||||
.filter(e -> !isSenderKey || e.groupId().isPresent())
|
.filter(e -> !isSenderKey || e.groupId().isPresent())
|
||||||
|
@ -131,7 +132,7 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public long insertIfPossible(
|
public long insertIfPossible(
|
||||||
long sentTimestamp, SendMessageResult sendMessageResult, ContentHint contentHint
|
long sentTimestamp, SendMessageResult sendMessageResult, ContentHint contentHint, boolean urgent
|
||||||
) {
|
) {
|
||||||
final RecipientDevices recipientDevice = getRecipientDevices(sendMessageResult);
|
final RecipientDevices recipientDevice = getRecipientDevices(sendMessageResult);
|
||||||
if (recipientDevice == null) {
|
if (recipientDevice == null) {
|
||||||
|
@ -141,11 +142,12 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
return insert(List.of(recipientDevice),
|
return insert(List.of(recipientDevice),
|
||||||
sentTimestamp,
|
sentTimestamp,
|
||||||
sendMessageResult.getSuccess().getContent().get(),
|
sendMessageResult.getSuccess().getContent().get(),
|
||||||
contentHint);
|
contentHint,
|
||||||
|
urgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long insertIfPossible(
|
public long insertIfPossible(
|
||||||
long sentTimestamp, List<SendMessageResult> sendMessageResults, ContentHint contentHint
|
long sentTimestamp, List<SendMessageResult> sendMessageResults, ContentHint contentHint, boolean urgent
|
||||||
) {
|
) {
|
||||||
final var recipientDevices = sendMessageResults.stream()
|
final var recipientDevices = sendMessageResults.stream()
|
||||||
.map(this::getRecipientDevices)
|
.map(this::getRecipientDevices)
|
||||||
|
@ -161,7 +163,7 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
return insert(recipientDevices, sentTimestamp, content, contentHint);
|
return insert(recipientDevices, sentTimestamp, content, contentHint, urgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRecipientToExistingEntryIfPossible(final long contentId, final SendMessageResult sendMessageResult) {
|
public void addRecipientToExistingEntryIfPossible(final long contentId, final SendMessageResult sendMessageResult) {
|
||||||
|
@ -272,10 +274,12 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
final List<RecipientDevices> recipientDevices,
|
final List<RecipientDevices> recipientDevices,
|
||||||
final long sentTimestamp,
|
final long sentTimestamp,
|
||||||
final SignalServiceProtos.Content content,
|
final SignalServiceProtos.Content content,
|
||||||
final ContentHint contentHint
|
final ContentHint contentHint,
|
||||||
|
final boolean urgent
|
||||||
) {
|
) {
|
||||||
byte[] groupId = getGroupId(content);
|
byte[] groupId = getGroupId(content);
|
||||||
|
|
||||||
|
// TODO store urgent
|
||||||
final var sql = """
|
final var sql = """
|
||||||
INSERT INTO %s (timestamp, group_id, content, content_hint)
|
INSERT INTO %s (timestamp, group_id, content, content_hint)
|
||||||
VALUES (?,?,?,?)
|
VALUES (?,?,?,?)
|
||||||
|
|
|
@ -19,7 +19,8 @@ public class MessageCacheUtils {
|
||||||
try (var f = new FileInputStream(file)) {
|
try (var f = new FileInputStream(file)) {
|
||||||
var in = new DataInputStream(f);
|
var in = new DataInputStream(f);
|
||||||
var version = in.readInt();
|
var version = in.readInt();
|
||||||
if (version > 5) {
|
if (version > 6) {
|
||||||
|
// Unsupported envelope version
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var type = in.readInt();
|
var type = in.readInt();
|
||||||
|
@ -63,6 +64,10 @@ public class MessageCacheUtils {
|
||||||
if (version >= 4) {
|
if (version >= 4) {
|
||||||
serverDeliveredTimestamp = in.readLong();
|
serverDeliveredTimestamp = in.readLong();
|
||||||
}
|
}
|
||||||
|
boolean isUrgent = true;
|
||||||
|
if (version >= 6) {
|
||||||
|
isUrgent = in.readBoolean();
|
||||||
|
}
|
||||||
Optional<SignalServiceAddress> addressOptional = sourceServiceId == null
|
Optional<SignalServiceAddress> addressOptional = sourceServiceId == null
|
||||||
? Optional.empty()
|
? Optional.empty()
|
||||||
: Optional.of(new SignalServiceAddress(sourceServiceId, source));
|
: Optional.of(new SignalServiceAddress(sourceServiceId, source));
|
||||||
|
@ -75,14 +80,15 @@ public class MessageCacheUtils {
|
||||||
serverReceivedTimestamp,
|
serverReceivedTimestamp,
|
||||||
serverDeliveredTimestamp,
|
serverDeliveredTimestamp,
|
||||||
uuid,
|
uuid,
|
||||||
destinationUuid == null ? UuidUtil.UNKNOWN_UUID.toString() : destinationUuid);
|
destinationUuid == null ? UuidUtil.UNKNOWN_UUID.toString() : destinationUuid,
|
||||||
|
isUrgent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeEnvelope(SignalServiceEnvelope envelope, File file) throws IOException {
|
public static void storeEnvelope(SignalServiceEnvelope envelope, File file) throws IOException {
|
||||||
try (var f = new FileOutputStream(file)) {
|
try (var f = new FileOutputStream(file)) {
|
||||||
try (var out = new DataOutputStream(f)) {
|
try (var out = new DataOutputStream(f)) {
|
||||||
out.writeInt(5); // version
|
out.writeInt(6); // version
|
||||||
out.writeInt(envelope.getType());
|
out.writeInt(envelope.getType());
|
||||||
out.writeUTF(envelope.getSourceE164().isPresent() ? envelope.getSourceE164().get() : "");
|
out.writeUTF(envelope.getSourceE164().isPresent() ? envelope.getSourceE164().get() : "");
|
||||||
out.writeUTF(envelope.getSourceUuid().isPresent() ? envelope.getSourceUuid().get() : "");
|
out.writeUTF(envelope.getSourceUuid().isPresent() ? envelope.getSourceUuid().get() : "");
|
||||||
|
@ -105,6 +111,7 @@ public class MessageCacheUtils {
|
||||||
var uuid = envelope.getServerGuid();
|
var uuid = envelope.getServerGuid();
|
||||||
out.writeUTF(uuid == null ? "" : uuid);
|
out.writeUTF(uuid == null ? "" : uuid);
|
||||||
out.writeLong(envelope.getServerDeliveredTimestamp());
|
out.writeLong(envelope.getServerDeliveredTimestamp());
|
||||||
|
out.writeBoolean(envelope.isUrgent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue