about summary refs log tree commit diff stats
path: root/src/command/cmd_funcs.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-04-08 10:20:42 +0200
committerGitHub <noreply@github.com>2021-04-08 10:20:42 +0200
commit558d672733c3bee3395b0236b8454a6af853301e (patch)
tree306c928deffe94c655ec80d2295d9f4cb5cf4244 /src/command/cmd_funcs.c
parent1ec606540eb0f474f3d968d3566a7c56d778a367 (diff)
parent025c2fb1e0ed0915c90d4371c2f96ce9f9c8f957 (diff)
downloadprofani-tty-558d672733c3bee3395b0236b8454a6af853301e.tar.gz
Merge pull request #1515 from mwuttke97/fix_omemo_empty_devlist
 [OMEMO] Fix sending messages
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r--src/command/cmd_funcs.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 8f463a6c..90c41dfd 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -2151,30 +2151,21 @@ cmd_msg(ProfWin* window, const char* const command, gchar** args)
 
         ProfChatWin* chatwin = wins_get_chat(barejid);
         if (!chatwin) {
+            // NOTE: This will also start the new OMEMO session and send a MAM request.
             chatwin = chatwin_new(barejid);
         }
         ui_focus_win((ProfWin*)chatwin);
 
-#ifdef HAVE_OMEMO
-        gboolean is_otr_secure = FALSE;
-
-#ifdef HAVE_LIBOTR
-        is_otr_secure = otr_is_secure(barejid);
-#endif // HAVE_LIBOTR
-
-        if (omemo_automatic_start(barejid) && is_otr_secure) {
-            win_println(window, THEME_DEFAULT, "!", "Chat could be either OMEMO or OTR encrypted. Use '/omemo start %s' or '/otr start %s' to start a session.", usr, usr);
-            return TRUE;
-        } else if (omemo_automatic_start(barejid)) {
-            omemo_start_session(barejid);
-            chatwin->is_omemo = TRUE;
-        }
-#endif // HAVE_OMEMO
-
         if (msg) {
+            // NOTE: In case the message is OMEMO encrypted, we can't be sure
+            // whether the key bundles of the recipient have already been
+            // received. In the case that *no* bundles have been received yet,
+            // the message won't be sent, and an error is shown to the user.
+            // Other cases are not handled here.
             cl_ev_send_msg(chatwin, msg, NULL);
         } else {
 #ifdef HAVE_LIBOTR
+            // Start the OTR session after this (i.e. the first) message was sent
             if (otr_is_secure(barejid)) {
                 chatwin_otr_secured(chatwin, otr_is_trusted(barejid));
             }