X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/a4e1d697884ea492f1f41c44b45e09b228255eb6..286070c054d617f376c88a9b24efa9c5cffaef6a:/src/main/java/org/asamk/signal/manager/Manager.java diff --git a/src/main/java/org/asamk/signal/manager/Manager.java b/src/main/java/org/asamk/signal/manager/Manager.java index 8364888c..b418d310 100644 --- a/src/main/java/org/asamk/signal/manager/Manager.java +++ b/src/main/java/org/asamk/signal/manager/Manager.java @@ -31,7 +31,6 @@ import org.asamk.signal.storage.contacts.ContactInfo; import org.asamk.signal.storage.groups.GroupInfo; import org.asamk.signal.storage.groups.JsonGroupStore; import org.asamk.signal.storage.protocol.JsonIdentityKeyStore; -import org.asamk.signal.storage.threads.ThreadInfo; import org.asamk.signal.util.IOUtils; import org.asamk.signal.util.Util; import org.signal.libsignal.metadata.InvalidMetadataMessageException; @@ -81,6 +80,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceContent; import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage; import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; import org.whispersystems.signalservice.api.messages.SignalServiceGroup; +import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage; import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifestUpload; import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifestUpload.StickerInfo; import org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage; @@ -99,7 +99,6 @@ import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage import org.whispersystems.signalservice.api.profiles.SignalServiceProfile; import org.whispersystems.signalservice.api.push.ContactTokenDetails; import org.whispersystems.signalservice.api.push.SignalServiceAddress; -import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException; import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions; import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException; import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException; @@ -137,6 +136,7 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.zip.ZipEntry; @@ -171,8 +171,12 @@ public class Manager implements Signal { return username; } + public SignalServiceAddress getSelfAddress() { + return account.getSelfAddress(); + } + private SignalServiceAccountManager getSignalServiceAccountManager() { - return new SignalServiceAccountManager(BaseConfig.serviceConfiguration, null, account.getUsername(), account.getPassword(), account.getDeviceId(), BaseConfig.USER_AGENT, timer); + return new SignalServiceAccountManager(BaseConfig.serviceConfiguration, account.getUuid(), account.getUsername(), account.getPassword(), account.getDeviceId(), BaseConfig.USER_AGENT, timer); } private IdentityKey getIdentity() { @@ -210,14 +214,15 @@ public class Manager implements Signal { migrateLegacyConfigs(); accountManager = getSignalServiceAccountManager(); - try { - if (account.isRegistered() && accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) { + if (account.isRegistered()) { + if (accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) { refreshPreKeys(); account.save(); } - } catch (AuthorizationFailedException e) { - System.err.println("Authorization failed, was the number registered elsewhere?"); - throw e; + if (account.getUuid() == null) { + account.setUuid(accountManager.getOwnUuid()); + account.save(); + } } } @@ -253,6 +258,8 @@ public class Manager implements Signal { if (username == null) { account = SignalAccount.createTemporaryAccount(identityKey, registrationId); } else { + account.getSignalProtocolStore().saveIdentity(username, identityKey.getPublicKey(), TrustLevel.TRUSTED_VERIFIED); + ProfileKey profileKey = KeyUtils.createProfileKey(); account = SignalAccount.create(dataPath, username, identityKey, registrationId, profileKey); account.save(); @@ -268,6 +275,7 @@ public class Manager implements Signal { createNewIdentity(); } account.setPassword(KeyUtils.createPassword()); + account.setUuid(null); accountManager = getSignalServiceAccountManager(); if (voiceVerification) { @@ -341,7 +349,7 @@ public class Manager implements Signal { throw new IOException("Received invalid profileKey", e); } } - account = SignalAccount.createLinkedAccount(dataPath, username, account.getPassword(), ret.getDeviceId(), ret.getIdentity(), account.getSignalProtocolStore().getLocalRegistrationId(), account.getSignalingKey(), profileKey); + account = SignalAccount.createLinkedAccount(dataPath, username, ret.getUuid(), account.getPassword(), ret.getDeviceId(), ret.getIdentity(), account.getSignalProtocolStore().getLocalRegistrationId(), account.getSignalingKey(), profileKey); refreshPreKeys(); @@ -419,10 +427,11 @@ public class Manager implements Signal { verificationCode = verificationCode.replace("-", ""); account.setSignalingKey(KeyUtils.createSignalingKey()); // TODO make unrestricted unidentified access configurable - accountManager.verifyAccountWithCode(verificationCode, account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, pin, null, getSelfUnidentifiedAccessKey(), false, capabilities); + UUID uuid = accountManager.verifyAccountWithCode(verificationCode, account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, pin, null, getSelfUnidentifiedAccessKey(), false, capabilities); //accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID))); account.setRegistered(true); + account.setUuid(uuid); account.setRegistrationLockPin(pin); refreshPreKeys(); @@ -499,12 +508,10 @@ public class Manager implements Signal { if (g == null) { throw new GroupNotFoundException(groupId); } - for (String member : g.members) { - if (member.equals(account.getUsername())) { - return g; - } + if (!g.isMember(account.getSelfAddress())) { + throw new NotAGroupMemberException(groupId, g.name); } - throw new NotAGroupMemberException(groupId, g.name); + return g; } public List getGroups() { @@ -514,7 +521,7 @@ public class Manager implements Signal { @Override public void sendGroupMessage(String messageText, List attachments, byte[] groupId) - throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, InvalidNumberException { + throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException { final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText); if (attachments != null) { messageBuilder.withAttachments(Utils.getSignalServiceAttachments(attachments)); @@ -525,26 +532,20 @@ public class Manager implements Signal { .build(); messageBuilder.asGroupMessage(group); } - ThreadInfo thread = account.getThreadStore().getThread(Base64.encodeBytes(groupId)); - if (thread != null) { - messageBuilder.withExpiration(thread.messageExpirationTime); - } final GroupInfo g = getGroupForSending(groupId); - final Collection membersSend = getSignalServiceAddresses(g.members); - // Don't send group message to ourself - membersSend.remove(account.getSelfAddress()); - sendMessageLegacy(messageBuilder, membersSend); + messageBuilder.withExpiration(g.messageExpirationTime); + + sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress())); } public void sendGroupMessageReaction(String emoji, boolean remove, SignalServiceAddress targetAuthor, long targetSentTimestamp, byte[] groupId) - throws IOException, EncapsulatedExceptions, AttachmentInvalidException, InvalidNumberException { + throws IOException, EncapsulatedExceptions, AttachmentInvalidException { SignalServiceDataMessage.Reaction reaction = new SignalServiceDataMessage.Reaction(emoji, remove, targetAuthor, targetSentTimestamp); final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() - .withReaction(reaction) - .withProfileKey(account.getProfileKey().serialize()); + .withReaction(reaction); if (groupId != null) { SignalServiceGroup group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.DELIVER) .withId(groupId) @@ -552,13 +553,10 @@ public class Manager implements Signal { messageBuilder.asGroupMessage(group); } final GroupInfo g = getGroupForSending(groupId); - final Collection membersSend = getSignalServiceAddresses(g.members); - // Don't send group message to ourself - membersSend.remove(account.getSelfAddress()); - sendMessageLegacy(messageBuilder, membersSend); + sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress())); } - public void sendQuitGroupMessage(byte[] groupId) throws GroupNotFoundException, IOException, EncapsulatedExceptions, InvalidNumberException { + public void sendQuitGroupMessage(byte[] groupId) throws GroupNotFoundException, IOException, EncapsulatedExceptions { SignalServiceGroup group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.QUIT) .withId(groupId) .build(); @@ -567,18 +565,18 @@ public class Manager implements Signal { .asGroupMessage(group); final GroupInfo g = getGroupForSending(groupId); - g.members.remove(account.getUsername()); + g.removeMember(account.getSelfAddress()); account.getGroupStore().updateGroup(g); - sendMessageLegacy(messageBuilder, getSignalServiceAddresses(g.members)); + sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress())); } - private byte[] sendUpdateGroupMessage(byte[] groupId, String name, Collection members, String avatarFile) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, InvalidNumberException { + private byte[] sendUpdateGroupMessage(byte[] groupId, String name, Collection members, String avatarFile) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException { GroupInfo g; if (groupId == null) { // Create new group g = new GroupInfo(KeyUtils.createGroupId()); - g.members.add(account.getUsername()); + g.addMembers(Collections.singleton(account.getSelfAddress())); } else { g = getGroupForSending(groupId); } @@ -588,25 +586,26 @@ public class Manager implements Signal { } if (members != null) { - Set newMembers = new HashSet<>(); - for (String member : members) { - member = Utils.canonicalizeNumber(member, account.getUsername()); - if (g.members.contains(member)) { + final Set newE164Members = new HashSet<>(); + for (SignalServiceAddress member : members) { + if (g.isMember(member) || !member.getNumber().isPresent()) { continue; } - newMembers.add(member); - g.members.add(member); + newE164Members.add(member.getNumber().get()); } - final List contacts = accountManager.getContacts(newMembers); - if (contacts.size() != newMembers.size()) { + + final List contacts = accountManager.getContacts(newE164Members); + if (contacts.size() != newE164Members.size()) { // Some of the new members are not registered on Signal for (ContactTokenDetails contact : contacts) { - newMembers.remove(contact.getNumber()); + newE164Members.remove(contact.getNumber()); } - System.err.println("Failed to add members " + Util.join(", ", newMembers) + " to group: Not registered on Signal"); + System.err.println("Failed to add members " + Util.join(", ", newE164Members) + " to group: Not registered on Signal"); System.err.println("Aborting…"); System.exit(1); } + + g.addMembers(members); } if (avatarFile != null) { @@ -619,10 +618,7 @@ public class Manager implements Signal { SignalServiceDataMessage.Builder messageBuilder = getGroupUpdateMessageBuilder(g); - final Collection membersSend = getSignalServiceAddresses(g.members); - // Don't send group message to ourself - membersSend.remove(account.getSelfAddress()); - sendMessageLegacy(messageBuilder, membersSend); + sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress())); return g.groupId; } @@ -632,7 +628,7 @@ public class Manager implements Signal { } GroupInfo g = getGroupForSending(groupId); - if (!g.members.contains(recipient.getNumber().get())) { + if (!g.isMember(recipient)) { return; } @@ -657,15 +653,9 @@ public class Manager implements Signal { } } - SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() - .asGroupMessage(group.build()); - - ThreadInfo thread = account.getThreadStore().getThread(Base64.encodeBytes(g.groupId)); - if (thread != null) { - messageBuilder.withExpiration(thread.messageExpirationTime); - } - - return messageBuilder; + return SignalServiceDataMessage.newBuilder() + .asGroupMessage(group.build()) + .withExpiration(g.messageExpirationTime); } private void sendGroupInfoRequest(byte[] groupId, SignalServiceAddress recipient) throws IOException, EncapsulatedExceptions { @@ -679,15 +669,18 @@ public class Manager implements Signal { SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() .asGroupMessage(group.build()); - ThreadInfo thread = account.getThreadStore().getThread(Base64.encodeBytes(groupId)); - if (thread != null) { - messageBuilder.withExpiration(thread.messageExpirationTime); - } - // Send group info request message to the recipient who sent us a message with this groupId sendMessageLegacy(messageBuilder, Collections.singleton(recipient)); } + private void sendReceipt(SignalServiceAddress remoteAddress, long messageId) throws IOException, UntrustedIdentityException { + SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.DELIVERY, + Collections.singletonList(messageId), + System.currentTimeMillis()); + + getMessageSender().sendReceipt(remoteAddress, getAccessFor(remoteAddress), receiptMessage); + } + @Override public void sendMessage(String message, List attachments, String recipient) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException { @@ -717,7 +710,6 @@ public class Manager implements Signal { messageBuilder.withAttachments(attachmentPointers); } - messageBuilder.withProfileKey(account.getProfileKey().serialize()); sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients)); } @@ -726,8 +718,7 @@ public class Manager implements Signal { throws IOException, EncapsulatedExceptions, AttachmentInvalidException, InvalidNumberException { SignalServiceDataMessage.Reaction reaction = new SignalServiceDataMessage.Reaction(emoji, remove, targetAuthor, targetSentTimestamp); final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() - .withReaction(reaction) - .withProfileKey(account.getProfileKey().serialize()); + .withReaction(reaction); sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients)); } @@ -819,9 +810,9 @@ public class Manager implements Signal { public List getGroupMembers(byte[] groupId) { GroupInfo group = getGroup(groupId); if (group == null) { - return new ArrayList<>(); + return Collections.emptyList(); } else { - return new ArrayList<>(group.members); + return new ArrayList<>(group.getMembersE164()); } } @@ -839,16 +830,25 @@ public class Manager implements Signal { if (avatar.isEmpty()) { avatar = null; } - return sendUpdateGroupMessage(groupId, name, members, avatar); + return sendUpdateGroupMessage(groupId, name, members == null ? null : getSignalServiceAddresses(members), avatar); } /** - * Change the expiration timer for a thread (number of groupId) + * Change the expiration timer for a contact */ - public void setExpirationTimer(String numberOrGroupId, int messageExpirationTimer) { - ThreadInfo thread = account.getThreadStore().getThread(numberOrGroupId); - thread.messageExpirationTime = messageExpirationTimer; - account.getThreadStore().updateThread(thread); + public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) { + ContactInfo c = account.getContactStore().getContact(address); + c.messageExpirationTime = messageExpirationTimer; + account.getContactStore().updateContact(c); + } + + /** + * Change the expiration timer for a group + */ + public void setExpirationTimer(byte[] groupId, int messageExpirationTimer) { + GroupInfo g = account.getGroupStore().getGroup(groupId); + g.messageExpirationTime = messageExpirationTimer; + account.getGroupStore().updateGroup(g); } /** @@ -997,7 +997,9 @@ public class Manager implements Signal { } private byte[] getSenderCertificate() throws IOException { - byte[] certificate = accountManager.getSenderCertificate(); + // TODO support UUID capable sender certificates + // byte[] certificate = accountManager.getSenderCertificate(); + byte[] certificate = accountManager.getSenderCertificateLegacy(); // TODO cache for a day return certificate; } @@ -1135,8 +1137,11 @@ public class Manager implements Signal { if (canonicalizedNumber.equals(username)) { signalServiceAddresses.add(account.getSelfAddress()); } else { - // TODO get corresponding uuid - signalServiceAddresses.add(new SignalServiceAddress(null, canonicalizedNumber)); + SignalServiceAddress address = new SignalServiceAddress(null, canonicalizedNumber); + ContactInfo contact = account.getContactStore().getContact(address); + signalServiceAddresses.add(contact == null + ? address + : contact.getAddress()); } } return signalServiceAddresses; @@ -1192,11 +1197,13 @@ public class Manager implements Signal { // Send to all individually, so sync messages are sent correctly List results = new ArrayList<>(recipients.size()); for (SignalServiceAddress address : recipients) { - ThreadInfo thread = account.getThreadStore().getThread(address.getNumber().get()); - if (thread != null) { - messageBuilder.withExpiration(thread.messageExpirationTime); + ContactInfo contact = account.getContactStore().getContact(address); + if (contact != null) { + messageBuilder.withExpiration(contact.messageExpirationTime); + messageBuilder.withProfileKey(account.getProfileKey().serialize()); } else { messageBuilder.withExpiration(0); + messageBuilder.withProfileKey(null); } message = messageBuilder.build(); try { @@ -1235,10 +1242,8 @@ public class Manager implements Signal { } private void handleSignalServiceDataMessage(SignalServiceDataMessage message, boolean isSync, SignalServiceAddress source, SignalServiceAddress destination, boolean ignoreAttachments) { - String threadId; if (message.getGroupInfo().isPresent()) { SignalServiceGroup groupInfo = message.getGroupInfo().get(); - threadId = Base64.encodeBytes(groupInfo.getGroupId()); GroupInfo group = account.getGroupStore().getGroup(groupInfo.getGroupId()); switch (groupInfo.getType()) { case UPDATE: @@ -1284,7 +1289,7 @@ public class Manager implements Signal { e.printStackTrace(); } } else { - group.members.remove(source.getNumber().get()); + group.removeMember(source); account.getGroupStore().updateGroup(group); } break; @@ -1300,25 +1305,30 @@ public class Manager implements Signal { } break; } - } else { - if (isSync) { - threadId = destination.getNumber().get(); - } else { - threadId = source.getNumber().get(); - } } if (message.isEndSession()) { handleEndSession(isSync ? destination.getNumber().get() : source.getNumber().get()); } if (message.isExpirationUpdate() || message.getBody().isPresent()) { - ThreadInfo thread = account.getThreadStore().getThread(threadId); - if (thread == null) { - thread = new ThreadInfo(); - thread.id = threadId; - } - if (thread.messageExpirationTime != message.getExpiresInSeconds()) { - thread.messageExpirationTime = message.getExpiresInSeconds(); - account.getThreadStore().updateThread(thread); + if (message.getGroupInfo().isPresent()) { + SignalServiceGroup groupInfo = message.getGroupInfo().get(); + GroupInfo group = account.getGroupStore().getGroup(groupInfo.getGroupId()); + if (group == null) { + group = new GroupInfo(groupInfo.getGroupId()); + } + if (group.messageExpirationTime != message.getExpiresInSeconds()) { + group.messageExpirationTime = message.getExpiresInSeconds(); + account.getGroupStore().updateGroup(group); + } + } else { + ContactInfo contact = account.getContactStore().getContact(isSync ? destination : source); + if (contact == null) { + contact = new ContactInfo(isSync ? destination : source); + } + if (contact.messageExpirationTime != message.getExpiresInSeconds()) { + contact.messageExpirationTime = message.getExpiresInSeconds(); + account.getContactStore().updateContact(contact); + } } } if (message.getAttachments().isPresent() && !ignoreAttachments) { @@ -1333,18 +1343,24 @@ public class Manager implements Signal { } } if (message.getProfileKey().isPresent() && message.getProfileKey().get().length == 32) { - if (source.equals(account.getSelfAddress())) { + if (source.matches(account.getSelfAddress())) { try { this.account.setProfileKey(new ProfileKey(message.getProfileKey().get())); } catch (InvalidInputException ignored) { } + ContactInfo contact = account.getContactStore().getContact(source); + if (contact != null) { + contact.profileKey = Base64.encodeBytes(message.getProfileKey().get()); + account.getContactStore().updateContact(contact); + } + } else { + ContactInfo contact = account.getContactStore().getContact(source); + if (contact == null) { + contact = new ContactInfo(source); + } + contact.profileKey = Base64.encodeBytes(message.getProfileKey().get()); + account.getContactStore().updateContact(contact); } - ContactInfo contact = account.getContactStore().getContact(source); - if (contact == null) { - contact = new ContactInfo(source); - } - contact.profileKey = Base64.encodeBytes(message.getProfileKey().get()); - account.getContactStore().updateContact(contact); } if (message.getPreviews().isPresent()) { final List previews = message.getPreviews().get(); @@ -1508,6 +1524,15 @@ public class Manager implements Signal { } if (content.getDataMessage().isPresent()) { SignalServiceDataMessage message = content.getDataMessage().get(); + + if (content.isNeedsReceipt()) { + try { + sendReceipt(sender, message.getTimestamp()); + } catch (IOException | UntrustedIdentityException e) { + e.printStackTrace(); + } + } + handleSignalServiceDataMessage(message, false, sender, account.getSelfAddress(), ignoreAttachments); } if (content.getSyncMessage().isPresent()) { @@ -1559,10 +1584,10 @@ public class Manager implements Signal { } syncGroup.addMembers(g.getMembers()); if (!g.isActive()) { - syncGroup.members.remove(account.getUsername()); + syncGroup.removeMember(account.getSelfAddress()); } else { // Add ourself to the member set as it's marked as active - syncGroup.members.add(account.getUsername()); + syncGroup.addMembers(Collections.singleton(account.getSelfAddress())); } syncGroup.blocked = g.isBlocked(); if (g.getColor().isPresent()) { @@ -1641,13 +1666,7 @@ public class Manager implements Signal { account.getSignalProtocolStore().saveIdentity(verifiedMessage.getDestination().getNumber().get(), verifiedMessage.getIdentityKey(), TrustLevel.fromVerifiedState(verifiedMessage.getVerified())); } if (c.getExpirationTimer().isPresent()) { - ThreadInfo thread = account.getThreadStore().getThread(c.getAddress().getNumber().get()); - if (thread == null) { - thread = new ThreadInfo(); - thread.id = c.getAddress().getNumber().get(); - } - thread.messageExpirationTime = c.getExpirationTimer().get(); - account.getThreadStore().updateThread(thread); + contact.messageExpirationTime = c.getExpirationTimer().get(); } contact.blocked = c.isBlocked(); contact.inboxPosition = c.getInboxPosition().orNull(); @@ -1775,10 +1794,9 @@ public class Manager implements Signal { try (OutputStream fos = new FileOutputStream(groupsFile)) { DeviceGroupsOutputStream out = new DeviceGroupsOutputStream(fos); for (GroupInfo record : account.getGroupStore().getGroups()) { - ThreadInfo info = account.getThreadStore().getThread(Base64.encodeBytes(record.groupId)); out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name), new ArrayList<>(record.getMembers()), createGroupAvatarAttachment(record.groupId), - record.members.contains(account.getUsername()), Optional.fromNullable(info != null ? info.messageExpirationTime : null), + record.isMember(account.getSelfAddress()), Optional.of(record.messageExpirationTime), Optional.fromNullable(record.color), record.blocked, Optional.fromNullable(record.inboxPosition), record.archived)); } } @@ -1811,7 +1829,6 @@ public class Manager implements Signal { DeviceContactsOutputStream out = new DeviceContactsOutputStream(fos); for (ContactInfo record : account.getContactStore().getContacts()) { VerifiedMessage verifiedMessage = null; - ThreadInfo info = account.getThreadStore().getThread(record.number); if (getIdentities().containsKey(record.number)) { JsonIdentityKeyStore.Identity currentIdentity = null; for (JsonIdentityKeyStore.Identity id : getIdentities().get(record.number)) { @@ -1832,7 +1849,7 @@ public class Manager implements Signal { out.write(new DeviceContact(record.getAddress(), Optional.fromNullable(record.name), createContactAvatarAttachment(record.number), Optional.fromNullable(record.color), Optional.fromNullable(verifiedMessage), Optional.fromNullable(profileKey), record.blocked, - Optional.fromNullable(info != null ? info.messageExpirationTime : null), + Optional.of(record.messageExpirationTime), Optional.fromNullable(record.inboxPosition), record.archived)); }