mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Handle early read receipt sync messages.
This commit is contained in:
@@ -556,6 +556,19 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
||||
public long getTimetamp() {
|
||||
return timetamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final SyncMessageId that = (SyncMessageId) o;
|
||||
return timetamp == that.timetamp && Objects.equals(recipientId, that.recipientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(recipientId, timetamp);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExpirationInfo {
|
||||
|
||||
@@ -534,12 +534,16 @@ public class MmsSmsDatabase extends Database {
|
||||
SignalDatabase.mms().updateViewedStories(syncMessageIds);
|
||||
}
|
||||
|
||||
public void setTimestampRead(@NonNull Recipient senderRecipient, @NonNull List<ReadMessage> readMessages, long proposedExpireStarted, @NonNull Map<Long, Long> threadToLatestRead) {
|
||||
/**
|
||||
* @return Unhandled ids
|
||||
*/
|
||||
public Collection<SyncMessageId> setTimestampRead(@NonNull Recipient senderRecipient, @NonNull List<ReadMessage> readMessages, long proposedExpireStarted, @NonNull Map<Long, Long> threadToLatestRead) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
|
||||
List<Pair<Long, Long>> expiringText = new LinkedList<>();
|
||||
List<Pair<Long, Long>> expiringMedia = new LinkedList<>();
|
||||
Set<Long> updatedThreads = new HashSet<>();
|
||||
List<Pair<Long, Long>> expiringText = new LinkedList<>();
|
||||
List<Pair<Long, Long>> expiringMedia = new LinkedList<>();
|
||||
Set<Long> updatedThreads = new HashSet<>();
|
||||
Collection<SyncMessageId> unhandled = new LinkedList<>();
|
||||
|
||||
db.beginTransaction();
|
||||
try {
|
||||
@@ -556,6 +560,10 @@ public class MmsSmsDatabase extends Database {
|
||||
|
||||
updatedThreads.addAll(textResult.threads);
|
||||
updatedThreads.addAll(mediaResult.threads);
|
||||
|
||||
if (textResult.threads.isEmpty() && mediaResult.threads.isEmpty()) {
|
||||
unhandled.add(new SyncMessageId(senderRecipient.getId(), readMessage.getTimestamp()));
|
||||
}
|
||||
}
|
||||
|
||||
for (long threadId : updatedThreads) {
|
||||
@@ -581,6 +589,8 @@ public class MmsSmsDatabase extends Database {
|
||||
for (long threadId : updatedThreads) {
|
||||
notifyConversationListeners(threadId);
|
||||
}
|
||||
|
||||
return unhandled;
|
||||
}
|
||||
|
||||
public int getQuotedMessagePosition(long threadId, long quoteId, @NonNull RecipientId recipientId) {
|
||||
|
||||
Reference in New Issue
Block a user