mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Update libsignal-service-java
This commit is contained in:
parent
f445cfb5c1
commit
30690785fd
19 changed files with 71 additions and 42 deletions
|
@ -14,7 +14,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
api("com.github.turasa:signal-service-java:2.15.3_unofficial_22")
|
||||
api("com.github.turasa:signal-service-java:2.15.3_unofficial_23")
|
||||
implementation("com.google.protobuf:protobuf-javalite:3.10.0")
|
||||
implementation("org.bouncycastle:bcprov-jdk15on:1.68")
|
||||
implementation("org.slf4j:slf4j-api:1.7.30")
|
||||
|
|
|
@ -74,11 +74,15 @@ public class AvatarStore {
|
|||
}
|
||||
|
||||
private File getContactAvatarFile(SignalServiceAddress address) {
|
||||
return new File(avatarsPath, "contact-" + address.getLegacyIdentifier());
|
||||
return new File(avatarsPath, "contact-" + getLegacyIdentifier(address));
|
||||
}
|
||||
|
||||
private String getLegacyIdentifier(final SignalServiceAddress address) {
|
||||
return address.getNumber().or(() -> address.getUuid().get().toString());
|
||||
}
|
||||
|
||||
private File getProfileAvatarFile(SignalServiceAddress address) {
|
||||
return new File(avatarsPath, "profile-" + address.getLegacyIdentifier());
|
||||
return new File(avatarsPath, "profile-" + getLegacyIdentifier(address));
|
||||
}
|
||||
|
||||
private void createAvatarsDir() throws IOException {
|
||||
|
|
|
@ -641,7 +641,7 @@ public class Manager implements Closeable {
|
|||
}
|
||||
} catch (InvalidKeyException ignored) {
|
||||
logger.warn("Got invalid identity key in profile for {}",
|
||||
resolveSignalServiceAddress(recipientId).getLegacyIdentifier());
|
||||
resolveSignalServiceAddress(recipientId).getIdentifier());
|
||||
}
|
||||
return profileAndCredential;
|
||||
}
|
||||
|
|
|
@ -176,7 +176,8 @@ public class GroupV2Helper {
|
|||
final var noUuidCapability = members.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.filter(address -> !address.getUuid().isPresent())
|
||||
.map(SignalServiceAddress::getLegacyIdentifier)
|
||||
.map(SignalServiceAddress::getNumber)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toSet());
|
||||
if (noUuidCapability.size() > 0) {
|
||||
logger.warn("Cannot create a V2 group as some members don't have a UUID: {}",
|
||||
|
|
|
@ -96,7 +96,7 @@ public class MessageCacheUtils {
|
|||
out.writeInt(0);
|
||||
}
|
||||
out.writeLong(envelope.getServerReceivedTimestamp());
|
||||
var uuid = envelope.getUuid();
|
||||
var uuid = envelope.getServerGuid();
|
||||
out.writeUTF(uuid == null ? "" : uuid);
|
||||
out.writeLong(envelope.getServerDeliveredTimestamp());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
|
||||
|
||||
private final DBusConnection conn;
|
||||
|
@ -36,7 +38,7 @@ public class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
|
|||
try {
|
||||
conn.sendMessage(new Signal.ReceiptReceived(objectPath, envelope.getTimestamp(),
|
||||
// A receipt envelope always has a source address
|
||||
envelope.getSourceAddress().getLegacyIdentifier()));
|
||||
getLegacyIdentifier(envelope.getSourceAddress())));
|
||||
} catch (DBusException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ public class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
|
|||
try {
|
||||
conn.sendMessage(new Signal.ReceiptReceived(objectPath,
|
||||
timestamp,
|
||||
sender.getLegacyIdentifier()));
|
||||
getLegacyIdentifier(sender)));
|
||||
} catch (DBusException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -69,7 +71,7 @@ public class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
|
|||
try {
|
||||
conn.sendMessage(new Signal.MessageReceived(objectPath,
|
||||
message.getTimestamp(),
|
||||
sender.getLegacyIdentifier(),
|
||||
getLegacyIdentifier(sender),
|
||||
groupId != null ? groupId : new byte[0],
|
||||
message.getBody().isPresent() ? message.getBody().get() : "",
|
||||
JsonDbusReceiveMessageHandler.getAttachments(message, m)));
|
||||
|
@ -91,10 +93,10 @@ public class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
|
|||
try {
|
||||
conn.sendMessage(new Signal.SyncMessageReceived(objectPath,
|
||||
transcript.getTimestamp(),
|
||||
sender.getLegacyIdentifier(),
|
||||
transcript.getDestination().isPresent() ? transcript.getDestination()
|
||||
.get()
|
||||
.getLegacyIdentifier() : "",
|
||||
getLegacyIdentifier(sender),
|
||||
transcript.getDestination().isPresent()
|
||||
? getLegacyIdentifier(transcript.getDestination().get())
|
||||
: "",
|
||||
groupId != null ? groupId : new byte[0],
|
||||
message.getBody().isPresent() ? message.getBody().get() : "",
|
||||
JsonDbusReceiveMessageHandler.getAttachments(message, m)));
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.Base64;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||
|
||||
final Manager m;
|
||||
|
@ -58,7 +60,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
var e = (ProtocolUntrustedIdentityException) exception;
|
||||
writer.println(
|
||||
"The user’s key is untrusted, either the user has reinstalled Signal or a third party sent this message.");
|
||||
final var recipientName = m.resolveSignalServiceAddress(e.getSender()).getLegacyIdentifier();
|
||||
final var recipientName = getLegacyIdentifier(m.resolveSignalServiceAddress(e.getSender()));
|
||||
writer.println(
|
||||
"Use 'signal-cli -u {} listIdentities -n {}', verify the key and run 'signal-cli -u {} trust -v \"FINGER_PRINT\" {}' to mark it as trusted",
|
||||
m.getUsername(),
|
||||
|
@ -341,7 +343,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
writer.println("Blocked numbers:");
|
||||
final var blockedList = syncMessage.getBlockedList().get();
|
||||
for (var address : blockedList.getAddresses()) {
|
||||
writer.println("- {}", address.getLegacyIdentifier());
|
||||
writer.println("- {}", getLegacyIdentifier(address));
|
||||
}
|
||||
}
|
||||
if (syncMessage.getVerified().isPresent()) {
|
||||
|
@ -457,7 +459,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
final PlainTextWriter writer, final SignalServiceDataMessage.Quote quote
|
||||
) {
|
||||
writer.println("Id: {}", quote.getId());
|
||||
writer.println("Author: {}", m.resolveSignalServiceAddress(quote.getAuthor()).getLegacyIdentifier());
|
||||
writer.println("Author: {}", getLegacyIdentifier(m.resolveSignalServiceAddress(quote.getAuthor())));
|
||||
writer.println("Text: {}", quote.getText());
|
||||
if (quote.getMentions() != null && quote.getMentions().size() > 0) {
|
||||
writer.println("Mentions:");
|
||||
|
@ -676,7 +678,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
|
||||
private String formatContact(SignalServiceAddress address) {
|
||||
final var number = address.getLegacyIdentifier();
|
||||
final var number = getLegacyIdentifier(address);
|
||||
String name = null;
|
||||
try {
|
||||
name = m.getContactOrProfileName(number);
|
||||
|
|
|
@ -6,6 +6,8 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class ListContactsCommand implements LocalCommand {
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +21,7 @@ public class ListContactsCommand implements LocalCommand {
|
|||
var contacts = m.getContacts();
|
||||
for (var c : contacts) {
|
||||
writer.println("Number: {} Name: {} Blocked: {}",
|
||||
m.resolveSignalServiceAddress(c.first()).getLegacyIdentifier(),
|
||||
getLegacyIdentifier(m.resolveSignalServiceAddress(c.first())),
|
||||
c.second().getName(),
|
||||
c.second().isBlocked());
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
|||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
@ -27,7 +27,7 @@ public class ListGroupsCommand implements LocalCommand {
|
|||
private static Set<String> resolveMembers(Manager m, Set<RecipientId> addresses) {
|
||||
return addresses.stream()
|
||||
.map(m::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getLegacyIdentifier)
|
||||
.map(Util::getLegacyIdentifier)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ import org.asamk.signal.manager.groups.LastGroupAdminException;
|
|||
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
||||
import org.asamk.signal.manager.storage.identities.IdentityInfo;
|
||||
import org.asamk.signal.util.ErrorUtils;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
import org.whispersystems.libsignal.util.Pair;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
|
||||
import org.whispersystems.signalservice.api.messages.SendMessageResult;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -29,6 +29,8 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class DbusSignalImpl implements Signal {
|
||||
|
||||
private final Manager m;
|
||||
|
@ -317,7 +319,7 @@ public class DbusSignalImpl implements Signal {
|
|||
return group.getMembers()
|
||||
.stream()
|
||||
.map(m::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getLegacyIdentifier)
|
||||
.map(Util::getLegacyIdentifier)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +426,7 @@ public class DbusSignalImpl implements Signal {
|
|||
var contacts = m.getContacts();
|
||||
for (var c : contacts) {
|
||||
if (name.equals(c.second().getName())) {
|
||||
numbers.add(m.resolveSignalServiceAddress(c.first()).getLegacyIdentifier());
|
||||
numbers.add(getLegacyIdentifier(m.resolveSignalServiceAddress(c.first())));
|
||||
}
|
||||
}
|
||||
// Try profiles if no contact name was found
|
||||
|
|
|
@ -4,9 +4,9 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.asamk.signal.manager.groups.GroupUtils;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
@ -36,7 +36,7 @@ class JsonGroupInfo {
|
|||
this.members = groupInfo.getMembers()
|
||||
.get()
|
||||
.stream()
|
||||
.map(SignalServiceAddress::getLegacyIdentifier)
|
||||
.map(Util::getLegacyIdentifier)
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
this.members = null;
|
||||
|
|
|
@ -6,6 +6,8 @@ import org.asamk.signal.manager.Manager;
|
|||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class JsonMention {
|
||||
|
||||
@JsonProperty
|
||||
|
@ -18,8 +20,8 @@ public class JsonMention {
|
|||
final int length;
|
||||
|
||||
JsonMention(SignalServiceDataMessage.Mention mention, Manager m) {
|
||||
this.name = m.resolveSignalServiceAddress(new SignalServiceAddress(mention.getUuid(), null))
|
||||
.getLegacyIdentifier();
|
||||
this.name = getLegacyIdentifier(m.resolveSignalServiceAddress(new SignalServiceAddress(mention.getUuid(),
|
||||
null)));
|
||||
this.start = mention.getStart();
|
||||
this.length = mention.getLength();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class JsonMessageEnvelope {
|
||||
|
||||
@JsonProperty
|
||||
|
@ -48,11 +50,11 @@ public class JsonMessageEnvelope {
|
|||
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content, Manager m) {
|
||||
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
|
||||
var source = envelope.getSourceAddress();
|
||||
this.source = source.getLegacyIdentifier();
|
||||
this.source = getLegacyIdentifier(source);
|
||||
this.sourceDevice = envelope.getSourceDevice();
|
||||
this.relay = source.getRelay().orNull();
|
||||
} else if (envelope.isUnidentifiedSender() && content != null) {
|
||||
this.source = content.getSender().getLegacyIdentifier();
|
||||
this.source = getLegacyIdentifier(content.getSender());
|
||||
this.sourceDevice = content.getSenderDevice();
|
||||
this.relay = null;
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class JsonQuote {
|
||||
|
||||
@JsonProperty
|
||||
|
@ -30,7 +32,7 @@ public class JsonQuote {
|
|||
|
||||
JsonQuote(SignalServiceDataMessage.Quote quote, Manager m) {
|
||||
this.id = quote.getId();
|
||||
this.author = m.resolveSignalServiceAddress(quote.getAuthor()).getLegacyIdentifier();
|
||||
this.author = getLegacyIdentifier(m.resolveSignalServiceAddress(quote.getAuthor()));
|
||||
this.text = quote.getText();
|
||||
|
||||
if (quote.getMentions() != null && quote.getMentions().size() > 0) {
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Reaction;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class JsonReaction {
|
||||
|
||||
@JsonProperty
|
||||
|
@ -21,7 +23,7 @@ public class JsonReaction {
|
|||
|
||||
JsonReaction(Reaction reaction, Manager m) {
|
||||
this.emoji = reaction.getEmoji();
|
||||
this.targetAuthor = m.resolveSignalServiceAddress(reaction.getTargetAuthor()).getLegacyIdentifier();
|
||||
this.targetAuthor = getLegacyIdentifier(m.resolveSignalServiceAddress(reaction.getTargetAuthor()));
|
||||
this.targetSentTimestamp = reaction.getTargetSentTimestamp();
|
||||
this.isRemove = reaction.isRemove();
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptMessage;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
class JsonSyncDataMessage extends JsonDataMessage {
|
||||
|
||||
|
@ -15,9 +15,7 @@ class JsonSyncDataMessage extends JsonDataMessage {
|
|||
JsonSyncDataMessage(SentTranscriptMessage transcriptMessage, Manager m) {
|
||||
super(transcriptMessage.getMessage(), m);
|
||||
|
||||
this.destination = transcriptMessage.getDestination()
|
||||
.transform(SignalServiceAddress::getLegacyIdentifier)
|
||||
.orNull();
|
||||
this.destination = transcriptMessage.getDestination().transform(Util::getLegacyIdentifier).orNull();
|
||||
}
|
||||
|
||||
JsonSyncDataMessage(Signal.SyncMessageReceived messageReceived) {
|
||||
|
|
|
@ -5,13 +5,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
enum JsonSyncMessageType {
|
||||
CONTACTS_SYNC,
|
||||
GROUPS_SYNC,
|
||||
|
@ -50,7 +52,7 @@ class JsonSyncMessage {
|
|||
.get()
|
||||
.getAddresses()
|
||||
.stream()
|
||||
.map(SignalServiceAddress::getLegacyIdentifier)
|
||||
.map(Util::getLegacyIdentifier)
|
||||
.collect(Collectors.toList());
|
||||
this.blockedGroupIds = syncMessage.getBlockedList()
|
||||
.get()
|
||||
|
@ -66,7 +68,7 @@ class JsonSyncMessage {
|
|||
this.readMessages = syncMessage.getRead()
|
||||
.get()
|
||||
.stream()
|
||||
.map(message -> new JsonSyncReadMessage(message.getSender().getLegacyIdentifier(),
|
||||
.map(message -> new JsonSyncReadMessage(getLegacyIdentifier(message.getSender()),
|
||||
message.getTimestamp()))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class ErrorUtils {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ErrorUtils.class);
|
||||
|
@ -42,17 +44,18 @@ public class ErrorUtils {
|
|||
}
|
||||
|
||||
public static String getErrorMessageFromSendMessageResult(SendMessageResult result) {
|
||||
var identifier = getLegacyIdentifier(result.getAddress());
|
||||
if (result.isNetworkFailure()) {
|
||||
return String.format("Network failure for \"%s\"", result.getAddress().getLegacyIdentifier());
|
||||
return String.format("Network failure for \"%s\"", identifier);
|
||||
} else if (result.isUnregisteredFailure()) {
|
||||
return String.format("Unregistered user \"%s\"", result.getAddress().getLegacyIdentifier());
|
||||
return String.format("Unregistered user \"%s\"", identifier);
|
||||
} else if (result.getIdentityFailure() != null) {
|
||||
return String.format("Untrusted Identity for \"%s\"", result.getAddress().getLegacyIdentifier());
|
||||
return String.format("Untrusted Identity for \"%s\"", identifier);
|
||||
} else if (result.getProofRequiredFailure() != null) {
|
||||
final var failure = result.getProofRequiredFailure();
|
||||
return String.format(
|
||||
"CAPTCHA proof required for sending to \"%s\", available options \"%s\" with token \"%s\", or wait \"%d\" seconds",
|
||||
result.getAddress().getLegacyIdentifier(),
|
||||
identifier,
|
||||
failure.getOptions()
|
||||
.stream()
|
||||
.map(ProofRequiredException.Option::toString)
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.util;
|
|||
import org.asamk.signal.manager.groups.GroupId;
|
||||
import org.asamk.signal.manager.groups.GroupIdFormatException;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
public class Util {
|
||||
|
||||
|
@ -30,4 +31,8 @@ public class Util {
|
|||
public static GroupId decodeGroupId(String groupId) throws GroupIdFormatException {
|
||||
return GroupId.fromBase64(groupId);
|
||||
}
|
||||
|
||||
public static String getLegacyIdentifier(final SignalServiceAddress address) {
|
||||
return address.getNumber().or(() -> address.getUuid().get().toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue