From 91e8a89b591caf93a5c3b3533f2a538806b181a3 Mon Sep 17 00:00:00 2001 From: MarcoPolo-PasTonMolo Date: Sun, 29 May 2022 16:57:02 +0300 Subject: Fix duplicate messages in chat with oneself. Messages would get duplicated when you chat with yourself, worse if you had omemo enabled the duplicated message would say something along the lines of "Your client doesn't support OMEMO". The cause was carbons when the message was sent from another client, whilst it was a sent and received message when profanity was the one to send it. This commit ignores the carbon message in the 1st case and ignores the received one in the 2nd. Fixes https://github.com/profanity-im/profanity/issues/1595 --- src/xmpp/message.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/xmpp') diff --git a/src/xmpp/message.c b/src/xmpp/message.c index dc3bc14f..97a1132e 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -1314,6 +1314,14 @@ _handle_carbons(xmpp_stanza_t* const stanza) return NULL; } + // Eliminate duplicate messages in chat with oneself when another client is sending a message + char* bare_from = xmpp_jid_bare(connection_get_ctx(), xmpp_stanza_get_from(message_stanza)); + if (g_strcmp0(bare_from, xmpp_stanza_get_to(message_stanza)) == 0) { + free(bare_from); + return NULL; + } + free(bare_from); + return message_stanza; } -- cgit 1.4.1-2-gfad0