mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-07 06:25:16 +01:00
Improve receipt message validations.
This commit is contained in:
committed by
Cody Henthorne
parent
d4924d2a13
commit
96f893652b
@@ -7,6 +7,7 @@ import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.delete
|
||||
import org.signal.core.util.deleteAll
|
||||
import org.signal.core.util.exists
|
||||
import org.signal.core.util.forEach
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.readToList
|
||||
@@ -127,6 +128,13 @@ class GroupReceiptTable(context: Context?, databaseHelper: SignalDatabase?) : Da
|
||||
}
|
||||
}
|
||||
|
||||
fun hasReceipt(mmsId: Long, recipientId: RecipientId): Boolean {
|
||||
return readableDatabase
|
||||
.exists(TABLE_NAME)
|
||||
.where("$MMS_ID = ? AND $RECIPIENT_ID = ?", mmsId, recipientId)
|
||||
.run()
|
||||
}
|
||||
|
||||
fun getGroupReceiptInfo(mmsId: Long): List<GroupReceiptInfo> {
|
||||
return readableDatabase
|
||||
.select()
|
||||
|
||||
@@ -5540,6 +5540,11 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
return emptySet()
|
||||
}
|
||||
|
||||
// Only allow updating receipts for a group message if the sender is actually a member (stories are excluded because a single story timestamp can map to multiple messages)
|
||||
if (!receiptData.forIndividualChat && receiptData.storyType == StoryType.NONE && !groupReceipts.hasReceipt(receiptData.messageId, receiptAuthor)) {
|
||||
return emptySet()
|
||||
}
|
||||
|
||||
if (!receiptData.marked) {
|
||||
// We set the receipt_timestamp to the max of the two values because that single column represents the timestamp of the last receipt of any type.
|
||||
// That means we want to update it for each new receipt type, but we never want the time to go backwards.
|
||||
|
||||
Reference in New Issue
Block a user