mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Replace sent_messages list with algo
For OMEMO we had a list with our sent messages.
It was used so that we don't decrypt our own messages in MUCs that come
in via reflection.
Recently for https://github.com/profanity-im/profanity/pull/1209 we
started to use origin-id and use an algorithm so we can detect our own
sent messages via checking origin-id.
Profanity uses the same id for the message ID and origin-id.
With 06f300a42c
we added the
message_is_sent_by_us() function.
We implemented XEP-0359 this way to fix
https://github.com/profanity-im/profanity/issues/1201 so that we don't
log our own messages in MUCs twice.
We can now check whether the message was sent by us using this function
and can get rid of the list.
Probably we could also put many parts of the sv_ev_room_message()
function inside (else) part of `if (!(g_strcmp0(mynick,
message->jid->resourcepart) == 0 && message_is_sent_by_us(message))) {`.
Have to look more closely whether any of this needs to be run in case
the message actually comes from us.
This commit is contained in:
parent
725cf3e47a
commit
4ecd4dea6a
@ -504,8 +504,6 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *c
|
||||
{
|
||||
assert(mucwin != NULL);
|
||||
|
||||
g_hash_table_insert(mucwin->sent_messages, strdup(id), NULL);
|
||||
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
char *mynick = muc_nick(mucwin->roomjid);
|
||||
|
||||
@ -529,7 +527,7 @@ mucwin_incoming_msg(ProfMucWin *mucwin, ProfMessage *message, GSList *mentions,
|
||||
assert(mucwin != NULL);
|
||||
int flags = 0;
|
||||
|
||||
if (message->id && g_hash_table_remove(mucwin->sent_messages, message->id)) {
|
||||
if (message_is_sent_by_us(message)) {
|
||||
/* Ignore reflection messages */
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +172,6 @@ typedef struct prof_muc_win_t {
|
||||
unsigned long memcheck;
|
||||
char *enctext;
|
||||
char *message_char;
|
||||
GHashTable *sent_messages;
|
||||
GDateTime *last_msg_timestamp;
|
||||
} ProfMucWin;
|
||||
|
||||
|
@ -198,7 +198,6 @@ 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,7 +561,6 @@ 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);
|
||||
|
||||
if (mucwin->last_msg_timestamp) {
|
||||
g_date_time_unref(mucwin->last_msg_timestamp);
|
||||
|
Loading…
Reference in New Issue
Block a user