use of org.thoughtcrime.securesms.jobmanager.Data in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigration method migrateMultiDeviceContactUpdateJob.
@NonNull
private JobData migrateMultiDeviceContactUpdateJob(@NonNull JobData jobData) {
String address = jobData.getData().hasString("address") ? jobData.getData().getString("address") : null;
Data updatedData = new Data.Builder().putString("recipient", address != null ? Recipient.external(application, address).getId().serialize() : null).putBoolean("force_sync", jobData.getData().getBoolean("force_sync")).build();
return jobData.withData(updatedData);
}
use of org.thoughtcrime.securesms.jobmanager.Data in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigration method migrateRetrieveProfileAvatarJob.
@NonNull
private JobData migrateRetrieveProfileAvatarJob(@NonNull JobData jobData) {
// noinspection ConstantConditions
String queueAddress = jobData.getQueueKey().substring("RetrieveProfileAvatarJob".length());
Recipient queueRecipient = Recipient.external(application, queueAddress);
String address = jobData.getData().getString("address");
Recipient recipient = Recipient.external(application, address);
Data updatedData = new Data.Builder().putString("recipient", recipient.getId().serialize()).putString("profile_avatar", jobData.getData().getString("profile_avatar")).build();
return jobData.withQueueKey("RetrieveProfileAvatarJob::" + queueRecipient.getId().toQueueKey()).withData(updatedData);
}
use of org.thoughtcrime.securesms.jobmanager.Data in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigration method migratePushGroupUpdateJob.
@NonNull
private JobData migratePushGroupUpdateJob(@NonNull JobData jobData) {
String address = jobData.getData().getString("source");
Recipient recipient = Recipient.external(application, address);
Data updatedData = new Data.Builder().putString("source", recipient.getId().serialize()).putString("group_id", jobData.getData().getString("group_id")).build();
return jobData.withData(updatedData);
}
use of org.thoughtcrime.securesms.jobmanager.Data in project Signal-Android by WhisperSystems.
the class PushProcessMessageQueueJobMigration method migratePushProcessMessageJob.
@NonNull
private static JobData migratePushProcessMessageJob(@NonNull Context context, @NonNull JobData jobData) throws IOException {
Data data = jobData.getData();
String suffix = "";
if (data.getInt("message_state") == 0) {
SignalServiceContent content = SignalServiceContent.deserialize(Base64.decode(data.getString("message_content")));
if (content != null && content.getDataMessage().isPresent() && content.getDataMessage().get().getGroupContext().isPresent()) {
Log.i(TAG, "Migrating a group message.");
try {
GroupId groupId = GroupUtil.idFromGroupContext(content.getDataMessage().get().getGroupContext().get());
Recipient recipient = Recipient.externalGroupExact(context, groupId);
suffix = recipient.getId().toQueueKey();
} catch (BadGroupIdException e) {
Log.w(TAG, "Bad groupId! Using default queue.");
}
} else if (content != null) {
Log.i(TAG, "Migrating an individual message.");
suffix = RecipientId.from(content.getSender()).toQueueKey();
}
} else {
Log.i(TAG, "Migrating an exception message.");
String exceptionSender = data.getString("exception_sender");
GroupId exceptionGroup = GroupId.parseNullableOrThrow(data.getStringOrDefault("exception_groupId", null));
if (exceptionGroup != null) {
suffix = Recipient.externalGroupExact(context, exceptionGroup).getId().toQueueKey();
} else if (exceptionSender != null) {
suffix = Recipient.external(context, exceptionSender).getId().toQueueKey();
}
}
return jobData.withQueueKey("__PUSH_PROCESS_JOB__" + suffix);
}
use of org.thoughtcrime.securesms.jobmanager.Data in project Signal-Android by WhisperSystems.
the class RetrieveProfileJobMigration method migrateRetrieveProfileJob.
@NonNull
private static JobData migrateRetrieveProfileJob(@NonNull JobData jobData) {
Data data = jobData.getData();
if (data.hasString("recipient")) {
Log.i(TAG, "Migrating job.");
String recipient = data.getString("recipient");
return jobData.withData(new Data.Builder().putStringArray("recipients", new String[] { recipient }).build());
} else {
return jobData;
}
}
Aggregations