mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Reduce usage of deprecated resolved methods
This commit is contained in:
parent
5427fa0132
commit
3357945a5a
2 changed files with 22 additions and 32 deletions
|
@ -528,12 +528,6 @@ public class Manager implements Closeable {
|
||||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
|
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profile getRecipientProfile(
|
|
||||||
SignalServiceAddress address
|
|
||||||
) {
|
|
||||||
return getRecipientProfile(resolveRecipient(address), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Profile getRecipientProfile(
|
public Profile getRecipientProfile(
|
||||||
RecipientId recipientId
|
RecipientId recipientId
|
||||||
) {
|
) {
|
||||||
|
@ -713,9 +707,10 @@ public class Manager implements Closeable {
|
||||||
public Pair<Long, List<SendMessageResult>> sendGroupMessageReaction(
|
public Pair<Long, List<SendMessageResult>> sendGroupMessageReaction(
|
||||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, GroupId groupId
|
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, GroupId groupId
|
||||||
) throws IOException, InvalidNumberException, NotAGroupMemberException, GroupNotFoundException {
|
) throws IOException, InvalidNumberException, NotAGroupMemberException, GroupNotFoundException {
|
||||||
|
var targetAuthorRecipientId = canonicalizeAndResolveRecipient(targetAuthor);
|
||||||
var reaction = new SignalServiceDataMessage.Reaction(emoji,
|
var reaction = new SignalServiceDataMessage.Reaction(emoji,
|
||||||
remove,
|
remove,
|
||||||
canonicalizeAndResolveSignalServiceAddress(targetAuthor),
|
resolveSignalServiceAddress(targetAuthorRecipientId),
|
||||||
targetSentTimestamp);
|
targetSentTimestamp);
|
||||||
final var messageBuilder = SignalServiceDataMessage.newBuilder().withReaction(reaction);
|
final var messageBuilder = SignalServiceDataMessage.newBuilder().withReaction(reaction);
|
||||||
|
|
||||||
|
@ -948,14 +943,15 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
g = (GroupInfoV1) group;
|
g = (GroupInfoV1) group;
|
||||||
|
|
||||||
if (!g.isMember(resolveRecipient(recipient))) {
|
final var recipientId = resolveRecipient(recipient);
|
||||||
|
if (!g.isMember(recipientId)) {
|
||||||
throw new NotAGroupMemberException(groupId, g.name);
|
throw new NotAGroupMemberException(groupId, g.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
var messageBuilder = getGroupUpdateMessageBuilder(g);
|
var messageBuilder = getGroupUpdateMessageBuilder(g);
|
||||||
|
|
||||||
// Send group message only to the recipient who requested it
|
// Send group message only to the recipient who requested it
|
||||||
return sendMessage(messageBuilder, Set.of(resolveRecipient(recipient)));
|
return sendMessage(messageBuilder, Set.of(recipientId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SignalServiceDataMessage.Builder getGroupUpdateMessageBuilder(GroupInfoV1 g) throws AttachmentInvalidException {
|
private SignalServiceDataMessage.Builder getGroupUpdateMessageBuilder(GroupInfoV1 g) throws AttachmentInvalidException {
|
||||||
|
@ -1065,9 +1061,10 @@ public class Manager implements Closeable {
|
||||||
public Pair<Long, List<SendMessageResult>> sendMessageReaction(
|
public Pair<Long, List<SendMessageResult>> sendMessageReaction(
|
||||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
|
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
|
||||||
) throws IOException, InvalidNumberException {
|
) throws IOException, InvalidNumberException {
|
||||||
|
var targetAuthorRecipientId = canonicalizeAndResolveRecipient(targetAuthor);
|
||||||
var reaction = new SignalServiceDataMessage.Reaction(emoji,
|
var reaction = new SignalServiceDataMessage.Reaction(emoji,
|
||||||
remove,
|
remove,
|
||||||
canonicalizeAndResolveSignalServiceAddress(targetAuthor),
|
resolveSignalServiceAddress(targetAuthorRecipientId),
|
||||||
targetSentTimestamp);
|
targetSentTimestamp);
|
||||||
final var messageBuilder = SignalServiceDataMessage.newBuilder().withReaction(reaction);
|
final var messageBuilder = SignalServiceDataMessage.newBuilder().withReaction(reaction);
|
||||||
return sendMessage(messageBuilder, getSignalServiceAddresses(recipients));
|
return sendMessage(messageBuilder, getSignalServiceAddresses(recipients));
|
||||||
|
@ -1288,7 +1285,7 @@ public class Manager implements Closeable {
|
||||||
final var addressesMissingUuid = new HashSet<SignalServiceAddress>();
|
final var addressesMissingUuid = new HashSet<SignalServiceAddress>();
|
||||||
|
|
||||||
for (var number : numbers) {
|
for (var number : numbers) {
|
||||||
final var resolvedAddress = canonicalizeAndResolveSignalServiceAddress(number);
|
final var resolvedAddress = resolveSignalServiceAddress(canonicalizeAndResolveRecipient(number));
|
||||||
if (resolvedAddress.getUuid().isPresent()) {
|
if (resolvedAddress.getUuid().isPresent()) {
|
||||||
signalServiceAddresses.add(resolvedAddress);
|
signalServiceAddresses.add(resolvedAddress);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1389,7 +1386,7 @@ public class Manager implements Closeable {
|
||||||
final var expirationTime = contact != null ? contact.getMessageExpirationTime() : 0;
|
final var expirationTime = contact != null ? contact.getMessageExpirationTime() : 0;
|
||||||
messageBuilder.withExpiration(expirationTime);
|
messageBuilder.withExpiration(expirationTime);
|
||||||
message = messageBuilder.build();
|
message = messageBuilder.build();
|
||||||
results.add(sendMessage(resolveSignalServiceAddress(recipientId), message));
|
results.add(sendMessage(recipientId, message));
|
||||||
}
|
}
|
||||||
return new Pair<>(timestamp, results);
|
return new Pair<>(timestamp, results);
|
||||||
}
|
}
|
||||||
|
@ -1423,9 +1420,10 @@ public class Manager implements Closeable {
|
||||||
private SendMessageResult sendSelfMessage(SignalServiceDataMessage message) throws IOException {
|
private SendMessageResult sendSelfMessage(SignalServiceDataMessage message) throws IOException {
|
||||||
var messageSender = createMessageSender();
|
var messageSender = createMessageSender();
|
||||||
|
|
||||||
var recipient = account.getSelfAddress();
|
var recipientId = account.getSelfRecipientId();
|
||||||
|
|
||||||
final var unidentifiedAccess = unidentifiedAccessHelper.getAccessFor(resolveRecipient(recipient));
|
final var unidentifiedAccess = unidentifiedAccessHelper.getAccessFor(recipientId);
|
||||||
|
var recipient = resolveSignalServiceAddress(recipientId);
|
||||||
var transcript = new SentTranscriptMessage(Optional.of(recipient),
|
var transcript = new SentTranscriptMessage(Optional.of(recipient),
|
||||||
message.getTimestamp(),
|
message.getTimestamp(),
|
||||||
message,
|
message,
|
||||||
|
@ -1447,11 +1445,11 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SendMessageResult sendMessage(
|
private SendMessageResult sendMessage(
|
||||||
SignalServiceAddress address, SignalServiceDataMessage message
|
RecipientId recipientId, SignalServiceDataMessage message
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var messageSender = createMessageSender();
|
var messageSender = createMessageSender();
|
||||||
|
|
||||||
final var recipientId = resolveRecipient(address);
|
final var address = resolveSignalServiceAddress(recipientId);
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
return messageSender.sendMessage(address, unidentifiedAccessHelper.getAccessFor(recipientId), message);
|
return messageSender.sendMessage(address, unidentifiedAccessHelper.getAccessFor(recipientId), message);
|
||||||
|
@ -1682,11 +1680,11 @@ public class Manager implements Closeable {
|
||||||
|
|
||||||
private void storeProfileKeysFromMembers(final DecryptedGroup group) {
|
private void storeProfileKeysFromMembers(final DecryptedGroup group) {
|
||||||
for (var member : group.getMembersList()) {
|
for (var member : group.getMembersList()) {
|
||||||
final var address = resolveRecipient(new SignalServiceAddress(UuidUtil.parseOrThrow(member.getUuid()
|
final var uuid = UuidUtil.parseOrThrow(member.getUuid().toByteArray());
|
||||||
.toByteArray()), null));
|
final var recipientId = account.getRecipientStore().resolveRecipient(uuid);
|
||||||
try {
|
try {
|
||||||
account.getProfileStore()
|
account.getProfileStore()
|
||||||
.storeProfileKey(address, new ProfileKey(member.getProfileKey().toByteArray()));
|
.storeProfileKey(recipientId, new ProfileKey(member.getProfileKey().toByteArray()));
|
||||||
} catch (InvalidInputException ignored) {
|
} catch (InvalidInputException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1723,8 +1721,8 @@ public class Manager implements Closeable {
|
||||||
content = decryptMessage(envelope);
|
content = decryptMessage(envelope);
|
||||||
} catch (org.whispersystems.libsignal.UntrustedIdentityException e) {
|
} catch (org.whispersystems.libsignal.UntrustedIdentityException e) {
|
||||||
if (!envelope.hasSource()) {
|
if (!envelope.hasSource()) {
|
||||||
final var recipientId = resolveRecipient(((org.whispersystems.libsignal.UntrustedIdentityException) e)
|
final var identifier = ((org.whispersystems.libsignal.UntrustedIdentityException) e).getName();
|
||||||
.getName());
|
final var recipientId = resolveRecipient(identifier);
|
||||||
try {
|
try {
|
||||||
account.getMessageCache().replaceSender(cachedMessage, recipientId);
|
account.getMessageCache().replaceSender(cachedMessage, recipientId);
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
|
@ -1834,8 +1832,8 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
if (cachedMessage[0] != null) {
|
if (cachedMessage[0] != null) {
|
||||||
if (exception instanceof org.whispersystems.libsignal.UntrustedIdentityException) {
|
if (exception instanceof org.whispersystems.libsignal.UntrustedIdentityException) {
|
||||||
final var recipientId = resolveRecipient(((org.whispersystems.libsignal.UntrustedIdentityException) exception)
|
final var identifier = ((org.whispersystems.libsignal.UntrustedIdentityException) exception).getName();
|
||||||
.getName());
|
final var recipientId = resolveRecipient(identifier);
|
||||||
queuedActions.add(new RetrieveProfileAction(recipientId));
|
queuedActions.add(new RetrieveProfileAction(recipientId));
|
||||||
if (!envelope.hasSource()) {
|
if (!envelope.hasSource()) {
|
||||||
try {
|
try {
|
||||||
|
@ -2550,14 +2548,6 @@ public class Manager implements Closeable {
|
||||||
theirIdentityKey);
|
theirIdentityKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public SignalServiceAddress canonicalizeAndResolveSignalServiceAddress(String identifier) throws InvalidNumberException {
|
|
||||||
var canonicalizedNumber = UuidUtil.isUuid(identifier)
|
|
||||||
? identifier
|
|
||||||
: PhoneNumberFormatter.formatNumber(identifier, account.getUsername());
|
|
||||||
return resolveSignalServiceAddress(canonicalizedNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SignalServiceAddress resolveSignalServiceAddress(String identifier) {
|
public SignalServiceAddress resolveSignalServiceAddress(String identifier) {
|
||||||
var address = Utils.getSignalServiceAddressFromIdentifier(identifier);
|
var address = Utils.getSignalServiceAddressFromIdentifier(identifier);
|
||||||
|
|
|
@ -414,7 +414,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
final var address = m.resolveSignalServiceAddress(recipientId);
|
final var address = m.resolveSignalServiceAddress(recipientId);
|
||||||
var number = address.getNumber().orNull();
|
var number = address.getNumber().orNull();
|
||||||
if (number != null) {
|
if (number != null) {
|
||||||
var profile = m.getRecipientProfile(address);
|
var profile = m.getRecipientProfile(recipientId);
|
||||||
if (profile != null && profile.getDisplayName().equals(name)) {
|
if (profile != null && profile.getDisplayName().equals(name)) {
|
||||||
numbers.add(number);
|
numbers.add(number);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue