use of org.thoughtcrime.securesms.database.MessageDatabase.ExpirationInfo in project Signal-Android by WhisperSystems.
the class MarkReadReceiver method process.
public static void process(@NonNull Context context, @NonNull List<MarkedMessageInfo> markedReadMessages) {
if (markedReadMessages.isEmpty())
return;
List<SyncMessageId> syncMessageIds = Stream.of(markedReadMessages).map(MarkedMessageInfo::getSyncMessageId).toList();
List<ExpirationInfo> mmsExpirationInfo = Stream.of(markedReadMessages).map(MarkedMessageInfo::getExpirationInfo).filter(ExpirationInfo::isMms).filter(info -> info.getExpiresIn() > 0 && info.getExpireStarted() <= 0).toList();
List<ExpirationInfo> smsExpirationInfo = Stream.of(markedReadMessages).map(MarkedMessageInfo::getExpirationInfo).filterNot(ExpirationInfo::isMms).filter(info -> info.getExpiresIn() > 0 && info.getExpireStarted() <= 0).toList();
scheduleDeletion(context, smsExpirationInfo, mmsExpirationInfo);
MultiDeviceReadUpdateJob.enqueue(syncMessageIds);
Map<Long, List<MarkedMessageInfo>> threadToInfo = Stream.of(markedReadMessages).collect(Collectors.groupingBy(MarkedMessageInfo::getThreadId));
Stream.of(threadToInfo).forEach(threadToInfoEntry -> {
Map<RecipientId, List<MarkedMessageInfo>> recipientIdToInfo = Stream.of(threadToInfoEntry.getValue()).map(info -> info).collect(Collectors.groupingBy(info -> info.getSyncMessageId().getRecipientId()));
Stream.of(recipientIdToInfo).forEach(entry -> {
long threadId = threadToInfoEntry.getKey();
RecipientId recipientId = entry.getKey();
List<MarkedMessageInfo> infos = entry.getValue();
SendReadReceiptJob.enqueue(threadId, recipientId, infos);
});
});
}
use of org.thoughtcrime.securesms.database.MessageDatabase.ExpirationInfo in project Signal-Android by WhisperSystems.
the class MarkReadReceiver method scheduleDeletion.
private static void scheduleDeletion(@NonNull Context context, @NonNull List<ExpirationInfo> smsExpirationInfo, @NonNull List<ExpirationInfo> mmsExpirationInfo) {
if (smsExpirationInfo.size() > 0) {
SignalDatabase.sms().markExpireStarted(Stream.of(smsExpirationInfo).map(ExpirationInfo::getId).toList(), System.currentTimeMillis());
}
if (mmsExpirationInfo.size() > 0) {
SignalDatabase.mms().markExpireStarted(Stream.of(mmsExpirationInfo).map(ExpirationInfo::getId).toList(), System.currentTimeMillis());
}
if (smsExpirationInfo.size() + mmsExpirationInfo.size() > 0) {
ExpiringMessageManager expirationManager = ApplicationDependencies.getExpiringMessageManager();
Stream.concat(Stream.of(smsExpirationInfo), Stream.of(mmsExpirationInfo)).forEach(info -> expirationManager.scheduleDeletion(info.getId(), info.isMms(), info.getExpiresIn()));
}
}
Aggregations