X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/e809792467f50ed482fa4a2fd6e5e1577d306e6f..24714454dd43fe2df8981d37c98bd5c4c1a69a45:/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 f18cb219..d75ac76b 100644 --- a/src/main/java/org/asamk/signal/manager/Manager.java +++ b/src/main/java/org/asamk/signal/manager/Manager.java @@ -188,10 +188,11 @@ public class Manager implements Signal { account.setPassword(KeyUtils.createPassword()); accountManager = new SignalServiceAccountManager(BaseConfig.serviceConfiguration, account.getUsername(), account.getPassword(), BaseConfig.USER_AGENT, timer); - if (voiceVerification) - accountManager.requestVoiceVerificationCode(); - else - accountManager.requestSmsVerificationCode(); + if (voiceVerification) { + accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.absent()); + } else { + accountManager.requestSmsVerificationCode(false, Optional.absent()); + } account.setRegistered(false); account.save(); @@ -772,6 +773,24 @@ public class Manager implements Signal { account.getSignalProtocolStore().saveIdentity(e.getE164Number(), e.getIdentityKey(), TrustLevel.UNTRUSTED); return Collections.emptyList(); } + } else if (recipientsTS.size() == 1 && recipientsTS.contains(new SignalServiceAddress(username))) { + SignalServiceAddress recipient = new SignalServiceAddress(username); + final Optional unidentifiedAccess = getAccessFor(recipient); + SentTranscriptMessage transcript = new SentTranscriptMessage(recipient.getNumber(), + message.getTimestamp(), + message, + message.getExpiresInSeconds(), + Collections.singletonMap(recipient.getNumber(), unidentifiedAccess.isPresent())); + SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forSentTranscript(transcript); + + List results = new ArrayList<>(recipientsTS.size()); + try { + messageSender.sendMessage(syncMessage, unidentifiedAccess); + } catch (UntrustedIdentityException e) { + account.getSignalProtocolStore().saveIdentity(e.getE164Number(), e.getIdentityKey(), TrustLevel.UNTRUSTED); + results.add(SendMessageResult.identityFailure(recipient, e.getIdentityKey())); + } + return results; } else { // Send to all individually, so sync messages are sent correctly List results = new ArrayList<>(recipientsTS.size()); @@ -1148,6 +1167,10 @@ public class Manager implements Signal { } if (c.getExpirationTimer().isPresent()) { ThreadInfo thread = account.getThreadStore().getThread(c.getNumber()); + if (thread == null) { + thread = new ThreadInfo(); + thread.id = c.getNumber(); + } thread.messageExpirationTime = c.getExpirationTimer().get(); account.getThreadStore().updateThread(thread); }