import org.whispersystems.signalservice.api.util.SleepTimer;
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
+import org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException;
import org.whispersystems.signalservice.internal.util.Base64;
import java.io.*;
}
} catch (AuthorizationFailedException e) {
System.err.println("Authorization failed, was the number registered elsewhere?");
+ throw e;
}
}
accountManager = new SignalServiceAccountManager(BaseConfig.serviceConfiguration, account.getUsername(), account.getPassword(), BaseConfig.USER_AGENT, timer);
if (voiceVerification) {
- accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.<String>absent());
+ accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.<String>absent(), Optional.<String>absent());
} else {
- accountManager.requestSmsVerificationCode(false, Optional.<String>absent());
+ accountManager.requestSmsVerificationCode(false, Optional.<String>absent(), Optional.<String>absent());
}
account.setRegistered(false);
// If this is the master device, other users can't send messages to this number anymore.
// If this is a linked device, other users can still send messages, but this device doesn't receive them anymore.
accountManager.setGcmId(Optional.<String>absent());
+
+ account.setRegistered(false);
+ account.save();
}
public String getDeviceLinkUri() throws TimeoutException, IOException {
}
}
- return SignalServiceDataMessage.newBuilder()
+ 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;
}
private void sendGroupInfoRequest(byte[] groupId, String recipient) throws IOException, EncapsulatedExceptions {
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
final List<String> membersSend = new ArrayList<>();
membersSend.add(recipient);
if (attachments != null) {
messageBuilder.withAttachments(Utils.getSignalServiceAttachments(attachments));
}
+ messageBuilder.withProfileKey(account.getProfileKey());
sendMessageLegacy(messageBuilder, recipients);
}
message = messageBuilder.build();
if (message.getGroupInfo().isPresent()) {
try {
- List<SendMessageResult> result = messageSender.sendMessage(new ArrayList<>(recipientsTS), getAccessFor(recipientsTS), message);
+ final boolean isRecipientUpdate = false;
+ List<SendMessageResult> result = messageSender.sendMessage(new ArrayList<>(recipientsTS), getAccessFor(recipientsTS), isRecipientUpdate, message);
for (SendMessageResult r : result) {
if (r.getIdentityFailure() != null) {
account.getSignalProtocolStore().saveIdentity(r.getAddress().getNumber(), r.getIdentityFailure().getIdentityKey(), TrustLevel.UNTRUSTED);
message.getTimestamp(),
message,
message.getExpiresInSeconds(),
- Collections.singletonMap(recipient.getNumber(), unidentifiedAccess.isPresent()));
+ Collections.singletonMap(recipient.getNumber(), unidentifiedAccess.isPresent()),
+ false);
SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forSentTranscript(transcript);
List<SendMessageResult> results = new ArrayList<>(recipientsTS.size());
}
}
- private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) throws InvalidMetadataMessageException, ProtocolInvalidMessageException, ProtocolDuplicateMessageException, ProtocolLegacyMessageException, ProtocolInvalidKeyIdException, InvalidMetadataVersionException, ProtocolInvalidVersionException, ProtocolNoSessionException, ProtocolInvalidKeyException, ProtocolUntrustedIdentityException, SelfSendException {
+ private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) throws InvalidMetadataMessageException, ProtocolInvalidMessageException, ProtocolDuplicateMessageException, ProtocolLegacyMessageException, ProtocolInvalidKeyIdException, InvalidMetadataVersionException, ProtocolInvalidVersionException, ProtocolNoSessionException, ProtocolInvalidKeyException, ProtocolUntrustedIdentityException, SelfSendException, UnsupportedDataMessageException {
SignalServiceCipher cipher = new SignalServiceCipher(new SignalServiceAddress(username), account.getSignalProtocolStore(), Utils.getCertificateValidator());
try {
return cipher.decrypt(envelope);