use of org.thoughtcrime.securesms.database.RecipientDatabase in project Signal-Android by WhisperSystems.
the class MessageContentProcessor method handleProfileKey.
private void handleProfileKey(@NonNull SignalServiceContent content, @NonNull byte[] messageProfileKeyBytes, @NonNull Recipient senderRecipient) {
RecipientDatabase database = SignalDatabase.recipients();
ProfileKey messageProfileKey = ProfileKeyUtil.profileKeyOrNull(messageProfileKeyBytes);
if (senderRecipient.isSelf()) {
if (!Objects.equals(ProfileKeyUtil.getSelfProfileKey(), messageProfileKey)) {
warn(content.getTimestamp(), "Saw a sync message whose profile key doesn't match our records. Scheduling a storage sync to check.");
StorageSyncHelper.scheduleSyncForDataChange();
}
} else if (messageProfileKey != null) {
if (database.setProfileKey(senderRecipient.getId(), messageProfileKey)) {
log(content.getTimestamp(), "Profile key on message from " + senderRecipient.getId() + " didn't match our local store. It has been updated.");
ApplicationDependencies.getJobManager().add(RetrieveProfileJob.forRecipient(senderRecipient.getId()));
}
} else {
warn(String.valueOf(content.getTimestamp()), "Ignored invalid profile key seen in message");
}
}
use of org.thoughtcrime.securesms.database.RecipientDatabase in project Signal-Android by WhisperSystems.
the class MessageRequestRepository method acceptMessageRequest.
void acceptMessageRequest(@NonNull LiveRecipient liveRecipient, long threadId, @NonNull Runnable onMessageRequestAccepted, @NonNull GroupChangeErrorCallback error) {
executor.execute(() -> {
if (liveRecipient.get().isPushV2Group()) {
try {
Log.i(TAG, "GV2 accepting invite");
GroupManager.acceptInvite(context, liveRecipient.get().requireGroupId().requireV2());
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
recipientDatabase.setProfileSharing(liveRecipient.getId(), true);
onMessageRequestAccepted.run();
} catch (GroupChangeException | IOException e) {
Log.w(TAG, e);
error.onError(GroupChangeFailureReason.fromException(e));
}
} else {
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
recipientDatabase.setProfileSharing(liveRecipient.getId(), true);
MessageSender.sendProfileKey(context, threadId);
List<MessageDatabase.MarkedMessageInfo> messageIds = SignalDatabase.threads().setEntireThreadRead(threadId);
ApplicationDependencies.getMessageNotifier().updateNotification(context);
MarkReadReceiver.process(context, messageIds);
List<MessageDatabase.MarkedMessageInfo> viewedInfos = SignalDatabase.mms().getViewedIncomingMessages(threadId);
SendViewedReceiptJob.enqueue(threadId, liveRecipient.getId(), viewedInfos);
if (TextSecurePreferences.isMultiDevice(context)) {
ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(liveRecipient.getId()));
}
onMessageRequestAccepted.run();
}
});
}
use of org.thoughtcrime.securesms.database.RecipientDatabase in project Signal-Android by WhisperSystems.
the class InviteReminderRepository method setHasSeenFirstInviteReminder.
@Override
public void setHasSeenFirstInviteReminder(Recipient recipient) {
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
recipientDatabase.setSeenFirstInviteReminder(recipient.getId());
}
use of org.thoughtcrime.securesms.database.RecipientDatabase in project Signal-Android by WhisperSystems.
the class InsightsRepository method getInsecureRecipients.
@Override
public void getInsecureRecipients(@NonNull Consumer<List<Recipient>> insecureRecipientsConsumer) {
SimpleTask.run(() -> {
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
List<RecipientId> unregisteredRecipients = recipientDatabase.getUninvitedRecipientsForInsights();
return Stream.of(unregisteredRecipients).map(Recipient::resolved).toList();
}, insecureRecipientsConsumer::accept);
}
use of org.thoughtcrime.securesms.database.RecipientDatabase in project Signal-Android by WhisperSystems.
the class InsightsRepository method sendSmsInvite.
@Override
public void sendSmsInvite(@NonNull Recipient recipient, Runnable onSmsMessageSent) {
SimpleTask.run(() -> {
Recipient resolved = recipient.resolve();
int subscriptionId = resolved.getDefaultSubscriptionId().or(-1);
String message = context.getString(R.string.InviteActivity_lets_switch_to_signal, context.getString(R.string.install_url));
MessageSender.send(context, new OutgoingTextMessage(resolved, message, subscriptionId), -1L, true, null, null);
RecipientDatabase database = SignalDatabase.recipients();
database.setHasSentInvite(recipient.getId());
return null;
}, v -> onSmsMessageSent.run());
}
Aggregations