changeset 2215:ba1a770dd632

Fix changeset 0c78d31c753d If encryption is not required, send the original message.
author Mikael Berthe <mikael@lilotux.net>
date Thu, 05 Nov 2015 20:54:22 +0100
parents ae1cb5b25e51
children fa516ef22145
files mcabber/mcabber/otr.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/otr.c	Thu Nov 05 19:47:59 2015 +0100
+++ b/mcabber/mcabber/otr.c	Thu Nov 05 20:54:22 2015 +0100
@@ -636,13 +636,21 @@
     g_free(htmlmsg);
   }
 
-  if (err || !newmessage)
+  if (err)
     return NULL; /* something went wrong, don't send the plain-message! */
 
   if (cb_policy(NULL, ctx) & OTRL_POLICY_REQUIRE_ENCRYPTION ||
       ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED)
     *encryption_status = 1;
 
+  if (!newmessage) {
+    if (*encryption_status == 1)
+      return NULL;  // This message should have been encrypted
+
+    // If not, the encryption was not required - send the original message
+    return g_strdup(msg);
+  }
+
   /* Check the new message is not empty */
   if (newmessage[0] || !msg[0]) {
     rmsg = g_strdup(newmessage);