diff options
| author | Kirill A. Korinsky <kirill@korins.ky> | 2026-06-07 23:23:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-07 23:23:43 +0200 |
| commit | 45723ac201c1905571f9f78c8c970828db97139a (patch) | |
| tree | a416f97376b686c5d0442b1bcf239c46d521398b | |
| parent | c030843fb6139db382ebc9f1c1ecf48408c880ce (diff) | |
Fix chat correction content item lookup (#1873)
Direct chat corrections are accepted by bare JID, but the latest
correction lookup still constrained the query by the original full
resource; a correction sent from another resource therefore produced no
matching correction row, returned -1, and wrote that sentinel into the
message content item's foreign id.
Align the lookup with the acceptance rule: retain occupant id matching
for MUC corrections, retain resource matching for non chat cases where
it is still meaningful, and avoid resource filtering for direct chat
corrections.
| -rw-r--r-- | libdino/src/service/message_correction.vala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libdino/src/service/message_correction.vala b/libdino/src/service/message_correction.vala index 2d710f1c..d1f1dc3d 100644 --- a/libdino/src/service/message_correction.vala +++ b/libdino/src/service/message_correction.vala @@ -195,7 +195,9 @@ public class MessageCorrection : StreamInteractionModule, MessageListener { .perform(); int current_correction_message_id = get_latest_correction_message_id(conversation, original_message); - if (content_item != null) { + if (current_correction_message_id == -1) warning("Stored correction but got no latest correction %i -> %i", correction_message.id, original_message.id); + + if (content_item != null && current_correction_message_id != -1) { db.content_item.update() .with(db.content_item.id, "=", content_item.id) .with(db.content_item.content_type, "=", 1) @@ -227,12 +229,15 @@ public class MessageCorrection : StreamInteractionModule, MessageListener { .with(db.message_correction.to_stanza_id, "=", message.edit_to ?? message.stanza_id) .order_by(db.message.time, "DESC"); - if (message.occupant_db_id != -1) { - qry.outer_join_with(db.message_occupant_id, db.message_occupant_id.message_id, db.message.id) - .with(db.message_occupant_id.occupant_id, "=", message.occupant_db_id); - } else if (message.counterpart.resourcepart != null) { - qry.with(db.message.counterpart_resource, "=", message.counterpart.resourcepart); + if (message.type_.is_muc_semantic()) { + if (message.occupant_db_id != -1) { + qry.outer_join_with(db.message_occupant_id, db.message_occupant_id.message_id, db.message.id) + .with(db.message_occupant_id.occupant_id, "=", message.occupant_db_id); + } else if (message.counterpart.resourcepart != null) { + qry.with(db.message.counterpart_resource, "=", message.counterpart.resourcepart); + } } + RowOption row = qry.single().row(); if (row.is_present()) { return row[db.message.id]; |
