From d39128ffd7ae67bdd6a41b143d8799c4ddd79a55 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 24 May 2020 16:01:03 +0200 Subject: Store current resource for sent message (if server didn't give us the resource we asked for) Some servers give out random resources. Then, we didn't deduplicate own messages afterwards because we saved the wrong resource. --- libdino/src/service/message_processor.vala | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libdino/src') diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala index 266482ac..0e390540 100644 --- a/libdino/src/service/message_processor.vala +++ b/libdino/src/service/message_processor.vala @@ -627,6 +627,12 @@ public class MessageProcessor : StreamInteractionModule, Object { stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, new_message, (_, res) => { try { stream.get_module(MessageModule.IDENTITY).send_message.end(res); + + // The server might not have given us the resource we asked for. In that case, store the actual resource the message was sent with. Relevant for deduplication. + Jid? current_own_jid = stream.get_flag(Bind.Flag.IDENTITY).my_jid; + if (!conversation.type_.is_muc_semantic() && current_own_jid != null && !current_own_jid.equals(message.ourpart)) { + message.ourpart = current_own_jid; + } } catch (IOStreamError e) { message.marked = Entities.Message.Marked.UNSENT; } -- cgit v1.2.3-70-g09d2