mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Fix link preview thumbnail not matching when receiving quote of edited message.
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user