From: AsamK Date: Fri, 9 Feb 2024 21:51:03 +0000 (+0100) Subject: Update dependencies X-Git-Tag: v0.13.0~18 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/fb85e1a0681052d2d229888e85bc49487e1b6987 Update dependencies --- diff --git a/lib/src/main/java/org/asamk/signal/manager/helper/SyncHelper.java b/lib/src/main/java/org/asamk/signal/manager/helper/SyncHelper.java index de3a495a..9fd5076d 100644 --- a/lib/src/main/java/org/asamk/signal/manager/helper/SyncHelper.java +++ b/lib/src/main/java/org/asamk/signal/manager/helper/SyncHelper.java @@ -6,10 +6,12 @@ import org.asamk.signal.manager.api.TrustLevel; import org.asamk.signal.manager.storage.SignalAccount; import org.asamk.signal.manager.storage.groups.GroupInfoV1; import org.asamk.signal.manager.storage.recipients.RecipientAddress; +import org.asamk.signal.manager.storage.recipients.RecipientId; import org.asamk.signal.manager.storage.stickers.StickerPack; import org.asamk.signal.manager.util.AttachmentUtils; import org.asamk.signal.manager.util.IOUtils; import org.asamk.signal.manager.util.MimeUtils; +import org.jetbrains.annotations.NotNull; import org.signal.libsignal.protocol.IdentityKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -138,42 +140,17 @@ public class SyncHelper { for (var contactPair : account.getContactStore().getContacts()) { final var recipientId = contactPair.first(); final var contact = contactPair.second(); - final var address = context.getRecipientHelper().resolveSignalServiceAddress(recipientId); - - var currentIdentity = account.getIdentityKeyStore().getIdentityInfo(address.getServiceId()); - VerifiedMessage verifiedMessage = null; - if (currentIdentity != null) { - verifiedMessage = new VerifiedMessage(address, - currentIdentity.getIdentityKey(), - currentIdentity.getTrustLevel().toVerifiedState(), - currentIdentity.getDateAddedTimestamp()); - } + final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId); - var profileKey = account.getProfileStore().getProfileKey(recipientId); - out.write(new DeviceContact(address, - Optional.ofNullable(contact.getName()), - createContactAvatarAttachment(new RecipientAddress(address)), - Optional.ofNullable(contact.color()), - Optional.ofNullable(verifiedMessage), - Optional.ofNullable(profileKey), - contact.isBlocked(), - Optional.of(contact.messageExpirationTime()), - Optional.empty(), - contact.isArchived())); + out.write(getDeviceContact(address, recipientId, contact)); } if (account.getProfileKey() != null) { // Send our own profile key as well - out.write(new DeviceContact(account.getSelfAddress(), - Optional.empty(), - Optional.empty(), - Optional.empty(), - Optional.empty(), - Optional.of(account.getProfileKey()), - false, - Optional.empty(), - Optional.empty(), - false)); + final var address = account.getSelfRecipientAddress(); + final var recipientId = account.getSelfRecipientId(); + final var contact = account.getContactStore().getContact(recipientId); + out.write(getDeviceContact(address, recipientId, contact)); } } @@ -199,6 +176,35 @@ public class SyncHelper { } } + @NotNull + private DeviceContact getDeviceContact( + final RecipientAddress address, final RecipientId recipientId, final Contact contact + ) throws IOException { + var currentIdentity = address.serviceId().isEmpty() + ? null + : account.getIdentityKeyStore().getIdentityInfo(address.serviceId().get()); + VerifiedMessage verifiedMessage = null; + if (currentIdentity != null) { + verifiedMessage = new VerifiedMessage(address.toSignalServiceAddress(), + currentIdentity.getIdentityKey(), + currentIdentity.getTrustLevel().toVerifiedState(), + currentIdentity.getDateAddedTimestamp()); + } + + var profileKey = account.getProfileStore().getProfileKey(recipientId); + return new DeviceContact(address.aci(), + address.number(), + Optional.ofNullable(contact == null ? null : contact.getName()), + createContactAvatarAttachment(address), + Optional.ofNullable(contact == null ? null : contact.color()), + Optional.ofNullable(verifiedMessage), + Optional.ofNullable(profileKey), + contact != null && contact.isBlocked(), + Optional.ofNullable(contact == null ? null : contact.messageExpirationTime()), + Optional.empty(), + contact != null && contact.isArchived()); + } + public SendMessageResult sendBlockedList() { var addresses = new ArrayList(); for (var record : account.getContactStore().getContacts()) { @@ -315,19 +321,19 @@ public class SyncHelper { throw e; } } - if (c == null) { + if (c == null || (c.getAci().isEmpty() && c.getE164().isEmpty())) { break; } - if (c.getAddress().matches(account.getSelfAddress()) && c.getProfileKey().isPresent()) { + final var address = new RecipientAddress(c.getAci(), Optional.empty(), c.getE164(), Optional.empty()); + if (address.matches(account.getSelfRecipientAddress()) && c.getProfileKey().isPresent()) { account.setProfileKey(c.getProfileKey().get()); } - final var recipientId = account.getRecipientTrustedResolver().resolveRecipientTrusted(c.getAddress()); + final var recipientId = account.getRecipientTrustedResolver().resolveRecipientTrusted(address); var contact = account.getContactStore().getContact(recipientId); final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact); if (c.getName().isPresent() && ( contact == null || ( - contact.givenName() == null - && contact.familyName() == null + contact.givenName() == null && contact.familyName() == null ) )) { builder.withGivenName(c.getName().get()); @@ -354,7 +360,7 @@ public class SyncHelper { account.getContactStore().storeContact(recipientId, builder.build()); if (c.getAvatar().isPresent()) { - downloadContactAvatar(c.getAvatar().get(), new RecipientAddress(c.getAddress())); + downloadContactAvatar(c.getAvatar().get(), address); } } } diff --git a/settings.gradle.kts b/settings.gradle.kts index e28f8eaf..2ff8bc5c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,16 +10,16 @@ dependencyResolutionManagement { library("jackson.databind", "com.fasterxml.jackson.core", "jackson-databind").version("2.16.1") library("argparse4j", "net.sourceforge.argparse4j", "argparse4j").version("0.9.0") library("dbusjava", "com.github.hypfvieh", "dbus-java-transport-native-unixsocket").version("5.0.0") - version("slf4j", "2.0.10") + version("slf4j", "2.0.12") library("slf4j.api", "org.slf4j", "slf4j-api").versionRef("slf4j") library("slf4j.jul", "org.slf4j", "jul-to-slf4j").versionRef("slf4j") library("logback", "ch.qos.logback", "logback-classic").version("1.4.14") - library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_94") + library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_95") library("sqlite", "org.xerial", "sqlite-jdbc").version("3.45.1.0") library("hikari", "com.zaxxer", "HikariCP").version("5.1.0") - library("junit.jupiter", "org.junit.jupiter", "junit-jupiter").version("5.10.1") - library("junit.launcher", "org.junit.platform", "junit-platform-launcher").version("1.10.1") + library("junit.jupiter", "org.junit.jupiter", "junit-jupiter").version("5.10.2") + library("junit.launcher", "org.junit.platform", "junit-platform-launcher").version("1.10.2") } } }