mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Merge pull request #1717 from MarcoPolo-PasTonMolo/fix/chat-with-self-duplicate-msgs
Fix duplicate messages in chat with oneself.
This commit is contained in:
commit
4d6bc1adf8
@ -60,6 +60,7 @@
|
|||||||
#include "ui/screen.h"
|
#include "ui/screen.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
#include "xmpp/roster_list.h"
|
#include "xmpp/roster_list.h"
|
||||||
|
#include "xmpp/connection.h"
|
||||||
|
|
||||||
#define CONS_WIN_TITLE "Profanity. Type /help for help information."
|
#define CONS_WIN_TITLE "Profanity. Type /help for help information."
|
||||||
#define XML_WIN_TITLE "XML Console"
|
#define XML_WIN_TITLE "XML Console"
|
||||||
@ -1192,8 +1193,11 @@ win_print_incoming(ProfWin* window, const char* const display_name_from, ProfMes
|
|||||||
if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) {
|
if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) {
|
||||||
_win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->barejid);
|
_win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->barejid);
|
||||||
} else {
|
} else {
|
||||||
|
// Prevent duplicate messages when current client is sending a message
|
||||||
|
if (g_strcmp0(message->from_jid->fulljid, connection_get_fulljid()) != 0) {
|
||||||
_win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain);
|
_win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(enc_char);
|
free(enc_char);
|
||||||
break;
|
break;
|
||||||
|
@ -1359,6 +1359,14 @@ _handle_carbons(xmpp_stanza_t* const stanza)
|
|||||||
return NULL;
|
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;
|
return message_stanza;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user