aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/content_item_store.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2025-11-01 21:30:36 +0100
committerfiaxh <git@lightrise.org>2025-11-01 21:30:36 +0100
commit4b17d6fdba95e35765e7305198f2ee28c1d42c2c (patch)
tree7bad455272fb3d46c06d900f423e4f0006912f1e /libdino/src/service/content_item_store.vala
parentd7872109b33451716309d084d651aedd14ec3c04 (diff)
Fix incoming message corrections in MUCs
Diffstat (limited to 'libdino/src/service/content_item_store.vala')
-rw-r--r--libdino/src/service/content_item_store.vala31
1 files changed, 22 insertions, 9 deletions
diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala
index b3ec5d67..11512a53 100644
--- a/libdino/src/service/content_item_store.vala
+++ b/libdino/src/service/content_item_store.vala
@@ -148,28 +148,41 @@ public class ContentItemStore : StreamInteractionModule, Object {
return null;
}
- public ContentItem? get_content_item_for_referencing_id(Conversation conversation, string message_id) {
- Row? row = get_content_item_row_for_referencing_id(conversation, message_id);
+ public ContentItem? get_content_item_for_message(Conversation conversation, Message message) {
+ Row? row = get_content_item_row_for_message(conversation, message);
+
if (row != null) {
return get_item_from_row(row, conversation);
}
return null;
}
- public int get_content_item_id_for_referencing_id(Conversation conversation, string message_id) {
- Row? row = get_content_item_row_for_referencing_id(conversation, message_id);
+ public ContentItem? get_content_item_for_referencing_id(Conversation conversation, string referencing_id) {
+ Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_referencing_id(referencing_id, conversation);
+ if (message == null) return null;
+
+ Row? row = get_content_item_row_for_message(conversation, message);
+
+ if (row != null) {
+ return get_item_from_row(row, conversation);
+ }
+ return null;
+ }
+
+ public int get_content_item_id_for_referencing_id(Conversation conversation, string referencing_id) {
+ Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_referencing_id(referencing_id, conversation);
+ if (message == null) return -1;
+
+ Row? row = get_content_item_row_for_message(conversation, message);
if (row != null) {
return row[db.content_item.id];
}
return -1;
}
- private Row? get_content_item_row_for_referencing_id(Conversation conversation, string message_id) {
+ private Row? get_content_item_row_for_message(Conversation conversation, Message message) {
var content_item_row = db.content_item.select();
- Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_referencing_id(message_id, conversation);
- if (message == null) return null;
-
RowOption file_transfer_row = db.file_transfer.select()
.with(db.file_transfer.account_id, "=", conversation.account.id)
.with(db.file_transfer.counterpart_id, "=", db.get_jid_id(conversation.counterpart))
@@ -182,7 +195,7 @@ public class ContentItemStore : StreamInteractionModule, Object {
.with(db.content_item.content_type, "=", 2);
} else {
// Check if this message has been corrected. In that case, the foreign id is the latest correction.
- int correction_message_db_id = stream_interactor.get_module(MessageCorrection.IDENTITY).get_latest_correction_message_id(conversation, message_id);
+ int correction_message_db_id = stream_interactor.get_module(MessageCorrection.IDENTITY).get_latest_correction_message_id(conversation, message);
int message_db_id = correction_message_db_id != -1 ? correction_message_db_id : message.id;
content_item_row.with(db.content_item.foreign_id, "=", message_db_id)