mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 23:47:26 +00:00
@@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.tracing.Trace;
|
||||
import org.thoughtcrime.securesms.util.CursorUtil;
|
||||
import org.whispersystems.libsignal.util.Pair;
|
||||
|
||||
import java.io.Closeable;
|
||||
@@ -422,9 +423,9 @@ public class MmsSmsDatabase extends Database {
|
||||
|
||||
public int getQuotedMessagePosition(long threadId, long quoteId, @NonNull RecipientId recipientId) {
|
||||
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId + " AND " + MmsSmsColumns.REMOTE_DELETED + " = 0";
|
||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
||||
|
||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.RECIPIENT_ID}, selection, order, null)) {
|
||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.RECIPIENT_ID, MmsSmsColumns.REMOTE_DELETED}, selection, order, null)) {
|
||||
boolean isOwnNumber = Recipient.resolved(recipientId).isSelf();
|
||||
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
@@ -432,7 +433,11 @@ public class MmsSmsDatabase extends Database {
|
||||
boolean recipientIdMatches = recipientId.equals(RecipientId.from(cursor.getLong(1)));
|
||||
|
||||
if (quoteIdMatches && (recipientIdMatches || isOwnNumber)) {
|
||||
return cursor.getPosition();
|
||||
if (CursorUtil.requireBoolean(cursor, MmsSmsColumns.REMOTE_DELETED)) {
|
||||
return -1;
|
||||
} else {
|
||||
return cursor.getPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -441,17 +446,22 @@ public class MmsSmsDatabase extends Database {
|
||||
|
||||
public int getMessagePositionInConversation(long threadId, long receivedTimestamp, @NonNull RecipientId recipientId) {
|
||||
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId + " AND " + MmsSmsColumns.REMOTE_DELETED + " = 0";
|
||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
||||
|
||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_RECEIVED, MmsSmsColumns.RECIPIENT_ID}, selection, order, null)) {
|
||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_RECEIVED, MmsSmsColumns.RECIPIENT_ID, MmsSmsColumns.REMOTE_DELETED}, selection, order, null)) {
|
||||
boolean isOwnNumber = Recipient.resolved(recipientId).isSelf();
|
||||
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
boolean timestampMatches = cursor.getLong(0) == receivedTimestamp;
|
||||
boolean recipientIdMatches = recipientId.equals(RecipientId.from(cursor.getLong(1)));
|
||||
|
||||
|
||||
if (timestampMatches && (recipientIdMatches || isOwnNumber)) {
|
||||
return cursor.getPosition();
|
||||
if (CursorUtil.requireBoolean(cursor, MmsSmsColumns.REMOTE_DELETED)) {
|
||||
return -1;
|
||||
} else {
|
||||
return cursor.getPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user