mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Improve incoming group message processing.
This commit is contained in:
@@ -313,18 +313,12 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) :
|
||||
* @return local db group revision or -1 if not present.
|
||||
*/
|
||||
fun getGroupV2Revision(groupId: GroupId.V2): Int {
|
||||
readableDatabase
|
||||
.select()
|
||||
return readableDatabase
|
||||
.select(V2_REVISION)
|
||||
.from(TABLE_NAME)
|
||||
.where("$GROUP_ID = ?", groupId.toString())
|
||||
.run()
|
||||
.use { cursor ->
|
||||
return if (cursor.moveToNext()) {
|
||||
cursor.getInt(cursor.getColumnIndexOrThrow(V2_REVISION))
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
.readToSingleInt(-1)
|
||||
}
|
||||
|
||||
fun isUnknownGroup(groupId: GroupId): Boolean {
|
||||
|
||||
@@ -2800,7 +2800,8 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
retrieved: IncomingMessage,
|
||||
candidateThreadId: Long = -1,
|
||||
editedMessage: MmsMessageRecord? = null,
|
||||
notifyObservers: Boolean = true
|
||||
notifyObservers: Boolean = true,
|
||||
skipThreadUpdate: Boolean = false
|
||||
): Optional<InsertResult> {
|
||||
val type = retrieved.toMessageType()
|
||||
|
||||
@@ -2901,7 +2902,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
messageRanges = retrieved.messageRanges,
|
||||
contentValues = contentValues,
|
||||
insertListener = null,
|
||||
updateThread = updateThread,
|
||||
updateThread = updateThread && !skipThreadUpdate,
|
||||
unarchive = true,
|
||||
poll = retrieved.poll,
|
||||
pollTerminate = retrieved.messageExtras?.pollTerminate,
|
||||
@@ -2971,7 +2972,8 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
threadId = threadId,
|
||||
threadWasNewlyCreated = threadIdResult.newlyCreated,
|
||||
insertedAttachments = insertedAttachments,
|
||||
quoteAttachmentId = quoteAttachments.firstOrNull()?.let { insertedAttachments?.get(it) }
|
||||
quoteAttachmentId = quoteAttachments.firstOrNull()?.let { insertedAttachments?.get(it) },
|
||||
needsThreadUpdate = updateThread && skipThreadUpdate
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -3576,8 +3578,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
val contentValuesThreadId = contentValues.getAsLong(THREAD_ID)
|
||||
|
||||
if (updateThread) {
|
||||
threads.setLastScrolled(contentValuesThreadId, 0)
|
||||
threads.update(threadId, unarchive)
|
||||
threads.updateForMessageInsert(threadId, unarchive)
|
||||
}
|
||||
|
||||
if (pinnedMessage != null && pinnedMessage.pinDurationInSeconds != PIN_FOREVER) {
|
||||
@@ -6093,7 +6094,8 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
val threadId: Long,
|
||||
val threadWasNewlyCreated: Boolean,
|
||||
val insertedAttachments: Map<Attachment, AttachmentId>? = null,
|
||||
val quoteAttachmentId: AttachmentId? = null
|
||||
val quoteAttachmentId: AttachmentId? = null,
|
||||
val needsThreadUpdate: Boolean = false
|
||||
)
|
||||
|
||||
data class MessageReceiptUpdate(
|
||||
|
||||
@@ -1686,6 +1686,11 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
.run()
|
||||
}
|
||||
|
||||
fun updateForMessageInsert(threadId: Long, unarchive: Boolean) {
|
||||
setLastScrolled(threadId, 0)
|
||||
update(threadId, unarchive)
|
||||
}
|
||||
|
||||
fun update(threadId: Long, unarchive: Boolean, syncThreadDelete: Boolean = true): Boolean {
|
||||
return update(
|
||||
threadId = threadId,
|
||||
|
||||
Reference in New Issue
Block a user