aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/service/content_item_store.vala8
-rw-r--r--libdino/src/service/file_transfer_storage.vala17
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;
}
}