|
|
|
@ -22,7 +22,6 @@ import org.thoughtcrime.securesms.dependencies.InjectableType;
|
|
|
|
|
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
|
|
|
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
|
|
|
import org.thoughtcrime.securesms.util.Base64;
|
|
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
|
|
|
import org.whispersystems.jobqueue.JobParameters;
|
|
|
|
|
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
|
|
|
@ -104,7 +103,11 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
|
|
|
|
|
getAvatar(recipient.getContactUri()),
|
|
|
|
|
Optional.fromNullable(recipient.getColor().serialize()),
|
|
|
|
|
verifiedMessage,
|
|
|
|
|
Optional.fromNullable(recipient.getProfileKey())));
|
|
|
|
|
Optional.fromNullable(recipient.getProfileKey()),
|
|
|
|
|
recipient.isBlocked(),
|
|
|
|
|
recipient.getExpireMessages() > 0 ?
|
|
|
|
|
Optional.of(recipient.getExpireMessages()) :
|
|
|
|
|
Optional.absent()));
|
|
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|
sendUpdate(messageSender, contactDataFile, false);
|
|
|
|
@ -131,23 +134,26 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
|
|
|
|
|
Collection<ContactData> contacts = ContactAccessor.getInstance().getContactsWithPush(context);
|
|
|
|
|
|
|
|
|
|
for (ContactData contactData : contacts) {
|
|
|
|
|
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
|
|
|
|
|
Address address = Address.fromExternal(context, contactData.numbers.get(0).number);
|
|
|
|
|
Recipient recipient = Recipient.from(context, address, false);
|
|
|
|
|
Optional<IdentityDatabase.IdentityRecord> identity = DatabaseFactory.getIdentityDatabase(context).getIdentity(address);
|
|
|
|
|
Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity);
|
|
|
|
|
Optional<String> name = Optional.fromNullable(contactData.name);
|
|
|
|
|
Optional<String> color = Optional.of(recipient.getColor().serialize());
|
|
|
|
|
Optional<byte[]> profileKey = Optional.fromNullable(recipient.getProfileKey());
|
|
|
|
|
|
|
|
|
|
out.write(new DeviceContact(address.toPhoneString(), name, getAvatar(contactUri), color, verified, profileKey));
|
|
|
|
|
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
|
|
|
|
|
Address address = Address.fromExternal(context, contactData.numbers.get(0).number);
|
|
|
|
|
Recipient recipient = Recipient.from(context, address, false);
|
|
|
|
|
Optional<IdentityDatabase.IdentityRecord> identity = DatabaseFactory.getIdentityDatabase(context).getIdentity(address);
|
|
|
|
|
Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity);
|
|
|
|
|
Optional<String> name = Optional.fromNullable(contactData.name);
|
|
|
|
|
Optional<String> color = Optional.of(recipient.getColor().serialize());
|
|
|
|
|
Optional<byte[]> profileKey = Optional.fromNullable(recipient.getProfileKey());
|
|
|
|
|
boolean blocked = recipient.isBlocked();
|
|
|
|
|
Optional<Integer> expireTimer = recipient.getExpireMessages() > 0 ? Optional.of(recipient.getExpireMessages()) : Optional.absent();
|
|
|
|
|
|
|
|
|
|
out.write(new DeviceContact(address.toPhoneString(), name, getAvatar(contactUri), color, verified, profileKey, blocked, expireTimer));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ProfileKeyUtil.hasProfileKey(context)) {
|
|
|
|
|
out.write(new DeviceContact(TextSecurePreferences.getLocalNumber(context),
|
|
|
|
|
Optional.absent(), Optional.absent(),
|
|
|
|
|
Optional.absent(), Optional.absent(),
|
|
|
|
|
Optional.of(ProfileKeyUtil.getProfileKey(context))));
|
|
|
|
|
Optional.of(ProfileKeyUtil.getProfileKey(context)),
|
|
|
|
|
false, Optional.absent()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|