From 7ce49d7d68f19fb49a33e907485d83da2c9131a3 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 23 Mar 2021 13:45:52 +0100 Subject: Fix regression in FileItem generation fixes #1019 --- libdino/src/service/content_item_store.vala | 8 ++++++-- libdino/src/service/file_transfer_storage.vala | 17 +++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala index 2de804a1..632918f2 100644 --- a/libdino/src/service/content_item_store.vala +++ b/libdino/src/service/content_item_store.vala @@ -56,9 +56,13 @@ public class ContentItemStore : StreamInteractionModule, Object { } break; case 2: - FileTransfer? file_transfer = stream_interactor.get_module(FileTransferStorage.IDENTITY).get_call_by_id(foreign_id); + FileTransfer? file_transfer = stream_interactor.get_module(FileTransferStorage.IDENTITY).get_file_by_id(foreign_id, conversation); if (file_transfer != null) { - var file_item = new FileItem(file_transfer, conversation, row[db.content_item.id]); + Message? message = null; + if (file_transfer.provider == 0 && file_transfer.info != null) { + message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(int.parse(file_transfer.info), conversation); + } + var file_item = new FileItem(file_transfer, conversation, row[db.content_item.id], message); items.add(file_item); } break; diff --git a/libdino/src/service/file_transfer_storage.vala b/libdino/src/service/file_transfer_storage.vala index b4876c34..1cc62403 100644 --- a/libdino/src/service/file_transfer_storage.vala +++ b/libdino/src/service/file_transfer_storage.vala @@ -27,10 +27,10 @@ namespace Dino { public void add_file(FileTransfer file_transfer) { file_transfer.persist(db); - cache_call(file_transfer); + cache_file(file_transfer); } - public FileTransfer? get_call_by_id(int id) { + public FileTransfer? get_file_by_id(int id, Conversation conversation) { FileTransfer? file_transfer = files_by_db_id[id]; if (file_transfer != null) { return file_transfer; @@ -38,15 +38,20 @@ namespace Dino { RowOption row_option = db.file_transfer.select().with(db.file_transfer.id, "=", id).row(); - return create_call_from_row_opt(row_option); + return create_file_from_row_opt(row_option, conversation); } - private FileTransfer? create_call_from_row_opt(RowOption row_opt) { + private FileTransfer? create_file_from_row_opt(RowOption row_opt, Conversation conversation) { if (!row_opt.is_present()) return null; try { FileTransfer file_transfer = new FileTransfer.from_row(db, row_opt.inner, FileManager.get_storage_dir()); - cache_call(file_transfer); + + if (conversation.type_.is_muc_semantic()) { + file_transfer.ourpart = conversation.counterpart.with_resource(file_transfer.ourpart.resourcepart); + } + + cache_file(file_transfer); return file_transfer; } catch (InvalidJidError e) { warning("Got file transfer with invalid Jid: %s", e.message); @@ -54,7 +59,7 @@ namespace Dino { return null; } - private void cache_call(FileTransfer file_transfer) { + private void cache_file(FileTransfer file_transfer) { files_by_db_id[file_transfer.id] = file_transfer; } } -- cgit v1.2.3-70-g09d2