Fix link preview thumbnail not matching when receiving quote of edited message.

This commit is contained in:
Clark 2023-04-24 12:43:41 -04:00 committed by GitHub
parent 43565d3414
commit 8505530547
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -1485,9 +1485,12 @@ public class AttachmentTable extends DatabaseTable {
return EncryptedMediaDataSource.createFor(attachmentSecret, dataInfo.file, dataInfo.random, dataInfo.length);
}
public void duplicateAttachmentsForMessage(long destinationMessageId, long sourceMessageId) {
public void duplicateAttachmentsForMessage(long destinationMessageId, long sourceMessageId, Collection<Long> excludedIds) {
SQLiteDatabaseExtensionsKt.withinTransaction(getWritableDatabase(), db -> {
db.execSQL("CREATE TEMPORARY TABLE tmp_part AS SELECT * FROM " + TABLE_NAME + " WHERE " + MMS_ID + " = ?", SqlUtil.buildArgs(sourceMessageId));
for (Long id : excludedIds) {
db.execSQL("DELETE FROM tmp_part WHERE " + ROW_ID + " = ?", SqlUtil.buildArgs(id));
}
db.execSQL("UPDATE tmp_part SET " + ROW_ID + " = NULL, " + MMS_ID + " = ?", SqlUtil.buildArgs(destinationMessageId));
db.execSQL("INSERT INTO " + TABLE_NAME + " SELECT * FROM tmp_part");
db.execSQL("DROP TABLE tmp_part");

View file

@ -2593,7 +2593,14 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
}
if (retrieved.attachments.isEmpty() && editedMessage?.id != null && attachments.getAttachmentsForMessage(editedMessage.id).isNotEmpty()) {
attachments.duplicateAttachmentsForMessage(messageId, editedMessage.id)
val linkPreviewAttachmentIds = HashSet<Long>()
for (linkPreview in editedMessage.linkPreviews) {
val attachmentId = linkPreview.attachmentId
if (attachmentId != null) {
linkPreviewAttachmentIds.add(attachmentId.rowId)
}
}
attachments.duplicateAttachmentsForMessage(messageId, editedMessage.id, linkPreviewAttachmentIds)
}
val isNotStoryGroupReply = retrieved.parentStoryId == null || !retrieved.parentStoryId.isGroupReply()