aboutsummaryrefslogtreecommitdiff
path: root/libdino/src
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src')
-rw-r--r--libdino/src/service/content_item_store.vala8
-rw-r--r--libdino/src/service/counterpart_interaction_manager.vala8
-rw-r--r--libdino/src/service/database.vala10
-rw-r--r--libdino/src/service/file_transfer_storage.vala17
4 files changed, 26 insertions, 17 deletions
diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala
index 6ab0529c..60b05a8b 100644
--- a/libdino/src/service/content_item_store.vala
+++ b/libdino/src/service/content_item_store.vala
@@ -57,9 +57,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/counterpart_interaction_manager.vala b/libdino/src/service/counterpart_interaction_manager.vala
index 5b9d1fff..03eb6c6f 100644
--- a/libdino/src/service/counterpart_interaction_manager.vala
+++ b/libdino/src/service/counterpart_interaction_manager.vala
@@ -67,8 +67,8 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
stream_interactor.module_manager.get_module(account, Xep.ChatMarkers.Module.IDENTITY).marker_received.connect( (stream, jid, marker, id, message_stanza) => {
on_chat_marker_received.begin(account, jid, marker, id, message_stanza);
});
- stream_interactor.module_manager.get_module(account, Xep.MessageDeliveryReceipts.Module.IDENTITY).receipt_received.connect((stream, jid, id) => {
- on_receipt_received(account, jid, id);
+ stream_interactor.module_manager.get_module(account, Xep.MessageDeliveryReceipts.Module.IDENTITY).receipt_received.connect((stream, jid, id, stanza) => {
+ on_receipt_received(account, jid, id, stanza);
});
stream_interactor.module_manager.get_module(account, Xep.ChatStateNotifications.Module.IDENTITY).chat_state_received.connect((stream, jid, state, stanza) => {
on_chat_state_received.begin(account, jid, state, stanza);
@@ -198,8 +198,8 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
}
}
- private void on_receipt_received(Account account, Jid jid, string id) {
- Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account, Conversation.Type.CHAT);
+ private void on_receipt_received(Account account, Jid jid, string id, MessageStanza stanza) {
+ Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(stanza.from, stanza.to, account, stanza.type_);
if (conversation == null) return;
handle_chat_marker(conversation, jid,Xep.ChatMarkers.MARKER_RECEIVED, id);
}
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index 9703260a..dab32749 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -427,21 +427,21 @@ public class Database : Qlite.Database {
}
if (oldVersion < 17) {
try {
- exec("DROP INDEX contentitem_localtime_counterpart_idx");
- exec("CREATE INDEX contentitem_conversation_hide_localtime_time_idx ON content_item (conversation_id, hide, local_time, time)");
+ exec("DROP INDEX IF EXISTS contentitem_localtime_counterpart_idx");
+ exec("CREATE INDEX IF NOT EXISTS contentitem_conversation_hide_localtime_time_idx ON content_item (conversation_id, hide, local_time, time)");
} catch (Error e) {
error("Failed to upgrade to database version 17: %s", e.message);
}
}
if (oldVersion < 18) {
try {
- exec("DROP INDEX contentitem_conversation_hide_localtime_time_idx");
+ exec("DROP INDEX IF EXISTS contentitem_conversation_hide_localtime_time_idx");
exec("CREATE INDEX IF NOT EXISTS contentitem_conversation_hide_time_idx ON content_item (conversation_id, hide, time)");
- exec("DROP INDEX message_account_counterpart_localtime_idx");
+ exec("DROP INDEX IF EXISTS message_account_counterpart_localtime_idx");
exec("CREATE INDEX IF NOT EXISTS message_account_counterpart_time_idx ON message (account_id, counterpart_id, time)");
- exec("DROP INDEX filetransfer_localtime_counterpart_idx");
+ exec("DROP INDEX IF EXISTS filetransfer_localtime_counterpart_idx");
} catch (Error e) {
error("Failed to upgrade to database version 18: %s", e.message);
}
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;
}
}