use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigration method migratePushGroupSendJob.
@NonNull
private JobData migratePushGroupSendJob(@NonNull JobData jobData) {
// noinspection ConstantConditions
Recipient queueRecipient = Recipient.external(application, jobData.getQueueKey());
String address = jobData.getData().hasString("filter_address") ? jobData.getData().getString("filter_address") : null;
RecipientId recipientId = address != null ? Recipient.external(application, address).getId() : null;
Data updatedData = new Data.Builder().putString("filter_recipient", recipientId != null ? recipientId.serialize() : null).putLong("message_id", jobData.getData().getLong("message_id")).build();
return jobData.withQueueKey(queueRecipient.getId().toQueueKey()).withData(updatedData);
}
use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.
the class EditSelfProfileRepository method getCurrentAvatar.
@Override
public void getCurrentAvatar(@NonNull Consumer<byte[]> avatarConsumer) {
RecipientId selfId = Recipient.self().getId();
if (AvatarHelper.hasAvatar(context, selfId)) {
SimpleTask.run(() -> {
try {
return StreamUtil.readFully(AvatarHelper.getAvatar(context, selfId));
} catch (IOException e) {
Log.w(TAG, e);
return null;
}
}, avatarConsumer::accept);
} else if (!excludeSystem) {
SystemProfileUtil.getSystemProfileAvatar(context, new ProfileMediaConstraints()).addListener(new ListenableFuture.Listener<byte[]>() {
@Override
public void onSuccess(byte[] result) {
avatarConsumer.accept(result);
}
@Override
public void onFailure(ExecutionException e) {
Log.w(TAG, e);
avatarConsumer.accept(null);
}
});
}
}
use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.
the class ReviewUtil method getProfileChangeRecordsForGroup.
@WorkerThread
@NonNull
public static List<MessageRecord> getProfileChangeRecordsForGroup(@NonNull Context context, @NonNull GroupId.V2 groupId) {
RecipientId recipientId = SignalDatabase.recipients().getByGroupId(groupId).get();
Long threadId = SignalDatabase.threads().getThreadIdFor(recipientId);
if (threadId == null) {
return Collections.emptyList();
} else {
return SignalDatabase.sms().getProfileChangeDetailsRecords(threadId, System.currentTimeMillis() - TIMEOUT);
}
}
use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.
the class ReviewCardDialogFragment method getRepository.
@NonNull
private ReviewCardRepository getRepository() throws BadGroupIdException {
RecipientId recipientId = getRecipientId();
GroupId.V2 groupId = getGroupId();
if (recipientId != null) {
return new ReviewCardRepository(requireContext(), recipientId);
} else if (groupId != null) {
return new ReviewCardRepository(requireContext(), groupId);
} else {
throw new AssertionError();
}
}
use of org.thoughtcrime.securesms.recipients.RecipientId in project Signal-Android by WhisperSystems.
the class EditGroupProfileRepository method getCurrentName.
@Override
public void getCurrentName(@NonNull Consumer<String> nameConsumer) {
SimpleTask.run(() -> {
RecipientId recipientId = getRecipientId();
Recipient recipient = Recipient.resolved(recipientId);
return SignalDatabase.groups().getGroup(recipientId).transform(groupRecord -> {
String title = groupRecord.getTitle();
return title == null ? "" : title;
}).or(() -> recipient.getGroupName(context));
}, nameConsumer::accept);
}
Aggregations