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;
migrateLegacyConfigs();
accountManager = getSignalServiceAccountManager();
- try {
- if (account.isRegistered()) {
- if (accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) {
- refreshPreKeys();
- account.save();
- }
- if (account.getUuid() == null) {
- account.setUuid(accountManager.getOwnUuid());
- account.save();
- }
+ if (account.isRegistered()) {
+ if (accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) {
+ refreshPreKeys();
+ account.save();
+ }
+ if (account.getUuid() == null) {
+ account.setUuid(accountManager.getOwnUuid());
+ account.save();
}
- } catch (AuthorizationFailedException e) {
- System.err.println("Authorization failed, was the number registered elsewhere?");
- throw e;
}
}
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();
createNewIdentity();
}
account.setPassword(KeyUtils.createPassword());
+ account.setUuid(null);
accountManager = getSignalServiceAccountManager();
if (voiceVerification) {
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)
messageBuilder.withAttachments(attachmentPointers);
}
- messageBuilder.withProfileKey(account.getProfileKey().serialize());
sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients));
}
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));
}
}
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;
}
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;
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 {