Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
AsamK committed Feb 9, 2024
1 parent c78299e commit fb85e1a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 41 deletions.
80 changes: 43 additions & 37 deletions lib/src/main/java/org/asamk/signal/manager/helper/SyncHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
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;
Expand Down Expand Up @@ -138,42 +140,17 @@ public void sendContacts() throws IOException {
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));
}
}

Expand All @@ -199,6 +176,35 @@ public void sendContacts() throws IOException {
}
}

@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<SignalServiceAddress>();
for (var record : account.getContactStore().getContacts()) {
Expand Down Expand Up @@ -315,19 +321,19 @@ public void handleSyncDeviceContacts(final InputStream input) throws IOException
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());
Expand All @@ -354,7 +360,7 @@ public void handleSyncDeviceContacts(final InputStream input) throws IOException
account.getContactStore().storeContact(recipientId, builder.build());

if (c.getAvatar().isPresent()) {
downloadContactAvatar(c.getAvatar().get(), new RecipientAddress(c.getAddress()));
downloadContactAvatar(c.getAvatar().get(), address);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
Expand Down

0 comments on commit fb85e1a

Please sign in to comment.