Rework MUC reflected message filtering
Reflected messages can't be filtered by nick only otherwise you might ignore messages comming from you on another devices. Consequently we maintain a list of sent messages id in mucwin. To be sure the id will be correctly reflected we use the origin-id stanza.
This commit is contained in:
@@ -478,10 +478,12 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge
|
||||
}
|
||||
|
||||
void
|
||||
mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, prof_enc_t enc_mode)
|
||||
mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode)
|
||||
{
|
||||
assert(mucwin != NULL);
|
||||
|
||||
g_hash_table_insert(mucwin->sent_messages, strdup(id), NULL);
|
||||
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
char *mynick = muc_nick(mucwin->roomjid);
|
||||
|
||||
@@ -500,10 +502,15 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, prof_enc_t en
|
||||
}
|
||||
|
||||
void
|
||||
mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, GSList *mentions, GList *triggers, prof_enc_t enc_mode)
|
||||
mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, const char *const id, GSList *mentions, GList *triggers, prof_enc_t enc_mode)
|
||||
{
|
||||
assert(mucwin != NULL);
|
||||
|
||||
if (g_hash_table_remove(mucwin->sent_messages, id)) {
|
||||
/* Ignore reflection messages */
|
||||
return;
|
||||
}
|
||||
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
char *mynick = muc_nick(mucwin->roomjid);
|
||||
|
||||
|
||||
@@ -162,8 +162,8 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char
|
||||
const char *const role, const char *const affiliation, const char *const actor, const char *const reason);
|
||||
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
|
||||
void mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message);
|
||||
void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, prof_enc_t enc_mode);
|
||||
void mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, GSList *mentions, GList *triggers, prof_enc_t enc_mode);
|
||||
void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode);
|
||||
void mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, const char *const id, GSList *mentions, GList *triggers, prof_enc_t enc_mode);
|
||||
void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject);
|
||||
void mucwin_requires_config(ProfMucWin *mucwin);
|
||||
void mucwin_info(ProfMucWin *mucwin);
|
||||
|
||||
@@ -172,6 +172,7 @@ typedef struct prof_muc_win_t {
|
||||
unsigned long memcheck;
|
||||
char *enctext;
|
||||
char *message_char;
|
||||
GHashTable *sent_messages;
|
||||
} ProfMucWin;
|
||||
|
||||
typedef struct prof_conf_win_t ProfConfWin;
|
||||
|
||||
@@ -198,6 +198,7 @@ win_create_muc(const char *const roomjid)
|
||||
new_win->enctext = NULL;
|
||||
new_win->message_char = NULL;
|
||||
new_win->is_omemo = FALSE;
|
||||
new_win->sent_messages = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
|
||||
|
||||
new_win->memcheck = PROFMUCWIN_MEMCHECK;
|
||||
|
||||
|
||||
@@ -561,6 +561,7 @@ wins_close_by_num(int i)
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
autocomplete_remove(wins_ac, mucwin->roomjid);
|
||||
autocomplete_remove(wins_close_ac, mucwin->roomjid);
|
||||
g_hash_table_remove_all(mucwin->sent_messages);
|
||||
break;
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
|
||||
Reference in New Issue
Block a user