feat(omemo): suppress repetitive missing device ID warnings

When sending OMEMO messages, we print a warning message for every
participant without a device ID on every single send:

```
Can't find a OMEMO device id for my@jid.org
```

This clutters the UI due to the high volume of repetitive information.

This is solved by tracking suppressed warnings within the window
structure. A warning for a specific JID and type is only shown once
per window context.

Suppression state is stored in the base ProfWin structure and managed
via helper functions (win_warn_needed, win_warn_sent). The state is
lazily initialized to save resources and automatically cleaned up when
the window is closed.

Warnings are explicitly reset when an OMEMO session is started or
ended to ensure users see fresh alerts when toggling encryption.
This commit is contained in:
Michael Vetter
2026-03-18 20:05:04 +01:00
parent 9de455ceea
commit 321ff57150
6 changed files with 74 additions and 1 deletions

View File

@@ -57,6 +57,7 @@
#include "plugins/plugins.h"
#include "ui/inputwin.h"
#include "ui/ui.h"
#include "ui/window.h"
#include "ui/window_list.h"
#include "xmpp/avatar.h"
#include "xmpp/chat_session.h"
@@ -8456,6 +8457,7 @@ cmd_omemo_start(ProfWin* window, const char* const command, gchar** args)
win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Initiating OMEMO session with %s...", chatwin->barejid);
omemo_start_session(chatwin->barejid);
chatwin->is_omemo = TRUE;
win_clear_warned_jids((ProfWin*)chatwin);
} else if (window->type == WIN_MUC) {
ProfMucWin* mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
@@ -8471,6 +8473,7 @@ cmd_omemo_start(ProfWin* window, const char* const command, gchar** args)
win_println((ProfWin*)mucwin, THEME_DEFAULT, "!", "Initiating OMEMO session in %s...", mucwin->roomjid);
omemo_start_muc_sessions(mucwin->roomjid);
mucwin->is_omemo = TRUE;
win_clear_warned_jids((ProfWin*)mucwin);
} else {
win_println(window, THEME_DEFAULT, "!", "MUC must be non-anonymous (i.e. be configured to present real jid to anyone) and members-only in order to support OMEMO.");
}
@@ -8589,6 +8592,7 @@ cmd_omemo_end(ProfWin* window, const char* const command, gchar** args)
chatwin->is_omemo = FALSE;
accounts_add_omemo_state(session_get_account_name(), chatwin->barejid, FALSE);
win_clear_warned_jids((ProfWin*)chatwin);
} else if (window->type == WIN_MUC) {
ProfMucWin* mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
@@ -8600,6 +8604,7 @@ cmd_omemo_end(ProfWin* window, const char* const command, gchar** args)
mucwin->is_omemo = FALSE;
accounts_add_omemo_state(session_get_account_name(), mucwin->roomjid, FALSE);
win_clear_warned_jids((ProfWin*)mucwin);
} else {
win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to start an OMEMO session.");
return TRUE;