mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-18 13:14:14 +00:00
Update libsignal-service
This commit is contained in:
parent
b4275414e1
commit
4a3d9d90a6
@ -3,7 +3,7 @@ slf4j = "2.0.17"
|
|||||||
junit = "6.0.3"
|
junit = "6.0.3"
|
||||||
micronaut-json-schema = "2.0.0-M8"
|
micronaut-json-schema = "2.0.0-M8"
|
||||||
micronaut-core = "4.9.3"
|
micronaut-core = "4.9.3"
|
||||||
signal-service = "2.15.3_unofficial_145"
|
signal-service = "2.15.3_unofficial_146"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
bouncycastle = "org.bouncycastle:bcprov-jdk18on:1.84"
|
bouncycastle = "org.bouncycastle:bcprov-jdk18on:1.84"
|
||||||
|
|||||||
@ -259,7 +259,7 @@ public interface Manager extends Closeable {
|
|||||||
RecipientIdentifier.Single recipient
|
RecipientIdentifier.Single recipient
|
||||||
) throws IOException;
|
) throws IOException;
|
||||||
|
|
||||||
SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException;
|
void sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException;
|
||||||
|
|
||||||
SendMessageResults sendMessageRequestResponse(
|
SendMessageResults sendMessageRequestResponse(
|
||||||
MessageEnvelope.Sync.MessageRequestResponse.Type type,
|
MessageEnvelope.Sync.MessageRequestResponse.Type type,
|
||||||
|
|||||||
@ -157,7 +157,7 @@ public record MessageEnvelope(
|
|||||||
dataMessage.getExpiresInSeconds(),
|
dataMessage.getExpiresInSeconds(),
|
||||||
dataMessage.isExpirationUpdate(),
|
dataMessage.isExpirationUpdate(),
|
||||||
dataMessage.isViewOnce(),
|
dataMessage.isViewOnce(),
|
||||||
dataMessage.isEndSession(),
|
false,
|
||||||
dataMessage.isProfileKeyUpdate(),
|
dataMessage.isProfileKeyUpdate(),
|
||||||
dataMessage.getProfileKey().isPresent(),
|
dataMessage.getProfileKey().isPresent(),
|
||||||
dataMessage.getReaction().map(r -> Reaction.from(r, recipientResolver, addressResolver)),
|
dataMessage.getReaction().map(r -> Reaction.from(r, recipientResolver, addressResolver)),
|
||||||
@ -1028,7 +1028,7 @@ public record MessageEnvelope(
|
|||||||
final AttachmentFileProvider fileProvider,
|
final AttachmentFileProvider fileProvider,
|
||||||
Exception exception
|
Exception exception
|
||||||
) {
|
) {
|
||||||
final var serviceId = envelope.getSourceServiceId().map(ServiceId::parseOrNull).orElse(null);
|
final var serviceId = envelope.getSourceServiceId();
|
||||||
final var source = !envelope.isUnidentifiedSender() && serviceId != null
|
final var source = !envelope.isUnidentifiedSender() && serviceId != null
|
||||||
? recipientResolver.resolveRecipient(serviceId)
|
? recipientResolver.resolveRecipient(serviceId)
|
||||||
: envelope.isUnidentifiedSender() && content != null
|
: envelope.isUnidentifiedSender() && content != null
|
||||||
|
|||||||
@ -142,10 +142,11 @@ public final class IncomingMessageHandler {
|
|||||||
final var actions = new ArrayList<HandleAction>();
|
final var actions = new ArrayList<HandleAction>();
|
||||||
SignalServiceContent content = null;
|
SignalServiceContent content = null;
|
||||||
Exception exception = null;
|
Exception exception = null;
|
||||||
envelope.getSourceServiceId().map(ServiceId::parseOrNull)
|
if (envelope.getSourceServiceId() != null) {
|
||||||
// Store uuid if we don't have it already
|
// Store uuid if we don't have it already
|
||||||
// uuid in envelope is sent by server
|
// uuid in envelope is sent by server
|
||||||
.ifPresent(serviceId -> account.getRecipientResolver().resolveRecipient(serviceId));
|
account.getRecipientResolver().resolveRecipient(envelope.getSourceServiceId());
|
||||||
|
}
|
||||||
if (!envelope.isReceipt()) {
|
if (!envelope.isReceipt()) {
|
||||||
final var destination = getDestination(envelope).serviceId();
|
final var destination = getDestination(envelope).serviceId();
|
||||||
try {
|
try {
|
||||||
@ -874,11 +875,6 @@ public final class IncomingMessageHandler {
|
|||||||
|
|
||||||
final var selfAddress = isSync ? source : destination;
|
final var selfAddress = isSync ? source : destination;
|
||||||
final var conversationPartnerAddress = isSync ? destination : source;
|
final var conversationPartnerAddress = isSync ? destination : source;
|
||||||
if (conversationPartnerAddress != null && message.isEndSession()) {
|
|
||||||
account.getAccountData(selfAddress.serviceId())
|
|
||||||
.getSessionStore()
|
|
||||||
.deleteAllSessions(conversationPartnerAddress.serviceId());
|
|
||||||
}
|
|
||||||
if (message.isExpirationUpdate() || message.getBody().isPresent()) {
|
if (message.isExpirationUpdate() || message.getBody().isPresent()) {
|
||||||
if (message.getGroupContext().isPresent()) {
|
if (message.getGroupContext().isPresent()) {
|
||||||
final var groupContext = message.getGroupContext().get();
|
final var groupContext = message.getGroupContext().get();
|
||||||
@ -1047,7 +1043,7 @@ public final class IncomingMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SignalServiceAddress getSenderAddress(SignalServiceEnvelope envelope, SignalServiceContent content) {
|
private SignalServiceAddress getSenderAddress(SignalServiceEnvelope envelope, SignalServiceContent content) {
|
||||||
final var serviceId = envelope.getSourceServiceId().map(ServiceId::parseOrNull).orElse(null);
|
final var serviceId = envelope.getSourceServiceId();
|
||||||
if (!envelope.isUnidentifiedSender() && serviceId != null) {
|
if (!envelope.isUnidentifiedSender() && serviceId != null) {
|
||||||
return new SignalServiceAddress(serviceId);
|
return new SignalServiceAddress(serviceId);
|
||||||
} else if (content != null) {
|
} else if (content != null) {
|
||||||
@ -1058,7 +1054,7 @@ public final class IncomingMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DeviceAddress getSender(SignalServiceEnvelope envelope, SignalServiceContent content) {
|
private DeviceAddress getSender(SignalServiceEnvelope envelope, SignalServiceContent content) {
|
||||||
final var serviceId = envelope.getSourceServiceId().map(ServiceId::parseOrNull).orElse(null);
|
final var serviceId = envelope.getSourceServiceId();
|
||||||
if (!envelope.isUnidentifiedSender() && serviceId != null) {
|
if (!envelope.isUnidentifiedSender() && serviceId != null) {
|
||||||
return new DeviceAddress(account.getRecipientResolver().resolveRecipient(serviceId),
|
return new DeviceAddress(account.getRecipientResolver().resolveRecipient(serviceId),
|
||||||
serviceId,
|
serviceId,
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import org.asamk.signal.manager.jobs.CleanOldPreKeysJob;
|
|||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
import org.asamk.signal.manager.storage.messageCache.CachedMessage;
|
import org.asamk.signal.manager.storage.messageCache.CachedMessage;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
import org.signal.core.models.ServiceId;
|
|
||||||
import org.signal.core.models.ServiceId.ACI;
|
import org.signal.core.models.ServiceId.ACI;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -150,10 +149,10 @@ public class ReceiveHelper {
|
|||||||
for (final var it : batch) {
|
for (final var it : batch) {
|
||||||
SignalServiceEnvelope envelope1 = new SignalServiceEnvelope(it.getEnvelope(),
|
SignalServiceEnvelope envelope1 = new SignalServiceEnvelope(it.getEnvelope(),
|
||||||
it.getServerDeliveredTimestamp());
|
it.getServerDeliveredTimestamp());
|
||||||
final var recipientId = envelope1.getSourceServiceId()
|
final var sourceServiceId = envelope1.getSourceServiceId();
|
||||||
.map(ServiceId::parseOrNull)
|
final var recipientId = sourceServiceId == null
|
||||||
.map(s -> account.getRecipientResolver().resolveRecipient(s))
|
? null
|
||||||
.orElse(null);
|
: account.getRecipientResolver().resolveRecipient(sourceServiceId);
|
||||||
logger.trace("Storing new message from {}", recipientId);
|
logger.trace("Storing new message from {}", recipientId);
|
||||||
// store message on disk, before acknowledging receipt to the server
|
// store message on disk, before acknowledging receipt to the server
|
||||||
cachedMessage[0] = account.getMessageCache().cacheMessage(envelope1, recipientId);
|
cachedMessage[0] = account.getMessageCache().cacheMessage(envelope1, recipientId);
|
||||||
@ -238,7 +237,7 @@ public class ReceiveHelper {
|
|||||||
if (exception instanceof UntrustedIdentityException) {
|
if (exception instanceof UntrustedIdentityException) {
|
||||||
logger.debug("Keeping message with untrusted identity in message cache");
|
logger.debug("Keeping message with untrusted identity in message cache");
|
||||||
final var address = ((UntrustedIdentityException) exception).getSender();
|
final var address = ((UntrustedIdentityException) exception).getSender();
|
||||||
if (envelope.getSourceServiceId().isEmpty() && address.aci().isPresent()) {
|
if (envelope.getSourceServiceId() == null && address.aci().isPresent()) {
|
||||||
final var recipientId = account.getRecipientResolver()
|
final var recipientId = account.getRecipientResolver()
|
||||||
.resolveRecipient(ACI.parseOrThrow(address.aci().get()));
|
.resolveRecipient(ACI.parseOrThrow(address.aci().get()));
|
||||||
try {
|
try {
|
||||||
@ -292,7 +291,7 @@ public class ReceiveHelper {
|
|||||||
cachedMessage.delete();
|
cachedMessage.delete();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (envelope.getSourceServiceId().isEmpty()) {
|
if (envelope.getSourceServiceId() == null) {
|
||||||
final var identifier = ((UntrustedIdentityException) exception).getSender();
|
final var identifier = ((UntrustedIdentityException) exception).getSender();
|
||||||
final var recipientId = account.getRecipientResolver()
|
final var recipientId = account.getRecipientResolver()
|
||||||
.resolveRecipient(new RecipientAddress(identifier));
|
.resolveRecipient(new RecipientAddress(identifier));
|
||||||
|
|||||||
@ -1091,16 +1091,7 @@ public class ManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException {
|
public void sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException {
|
||||||
var messageBuilder = SignalServiceDataMessage.newBuilder().asEndSessionMessage();
|
|
||||||
|
|
||||||
try {
|
|
||||||
return sendMessage(messageBuilder,
|
|
||||||
recipients.stream().map(RecipientIdentifier.class::cast).collect(Collectors.toSet()),
|
|
||||||
false);
|
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
} finally {
|
|
||||||
for (var recipient : recipients) {
|
for (var recipient : recipients) {
|
||||||
final RecipientId recipientId;
|
final RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
@ -1108,13 +1099,18 @@ public class ManagerImpl implements Manager {
|
|||||||
} catch (UnregisteredRecipientException e) {
|
} catch (UnregisteredRecipientException e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final var serviceId = context.getAccount()
|
final var recipientAddress = context.getAccount()
|
||||||
.getRecipientAddressResolver()
|
.getRecipientAddressResolver()
|
||||||
.resolveRecipientAddress(recipientId)
|
.resolveRecipientAddress(recipientId);
|
||||||
.serviceId();
|
final var aciSessionStore = account.getAccountData(ServiceIdType.ACI).getSessionStore();
|
||||||
if (serviceId.isPresent()) {
|
final var pniSessionStore = account.getAccountData(ServiceIdType.PNI).getSessionStore();
|
||||||
account.getAccountData(ServiceIdType.ACI).getSessionStore().deleteAllSessions(serviceId.get());
|
if (recipientAddress.aci().isPresent()) {
|
||||||
|
aciSessionStore.archiveSessions(recipientAddress.aci().get());
|
||||||
|
pniSessionStore.archiveSessions(recipientAddress.aci().get());
|
||||||
}
|
}
|
||||||
|
if (recipientAddress.pni().isPresent()) {
|
||||||
|
aciSessionStore.archiveSessions(recipientAddress.pni().get());
|
||||||
|
pniSessionStore.archiveSessions(recipientAddress.pni().get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,8 +144,7 @@ public class SendCommand implements JsonRpcLocalCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final var results = m.sendEndSessionMessage(singleRecipients);
|
m.sendEndSessionMessage(singleRecipients);
|
||||||
outputResult(outputWriter, results);
|
|
||||||
return;
|
return;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
|
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
|
||||||
|
|||||||
@ -543,9 +543,8 @@ public class DbusManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendEndSessionMessage(final Set<RecipientIdentifier.Single> recipients) throws IOException {
|
public void sendEndSessionMessage(final Set<RecipientIdentifier.Single> recipients) throws IOException {
|
||||||
signal.sendEndSessionMessage(recipients.stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
signal.sendEndSessionMessage(recipients.stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
||||||
return new SendMessageResults(0, Map.of());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -430,8 +430,7 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||||||
@Override
|
@Override
|
||||||
public void sendEndSessionMessage(final List<String> recipients) {
|
public void sendEndSessionMessage(final List<String> recipients) {
|
||||||
try {
|
try {
|
||||||
final var results = m.sendEndSessionMessage(getSingleRecipientIdentifiers(recipients, m.getSelfNumber()));
|
m.sendEndSessionMessage(getSingleRecipientIdentifiers(recipients, m.getSelfNumber()));
|
||||||
checkSendMessageResults(results);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -326,8 +326,7 @@ class SseInitialFlushTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) {
|
public void sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) {
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -328,8 +328,7 @@ class SubscribeCallEventsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> r) {
|
public void sendEndSessionMessage(Set<RecipientIdentifier.Single> r) {
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user