Fix changeset 0c78d31c753d
authorMikael Berthe <mikael@lilotux.net>
Thu, 05 Nov 2015 20:54:22 +0100
changeset 2215 ba1a770dd632
parent 2214 ae1cb5b25e51
child 2216 fa516ef22145
Fix changeset 0c78d31c753d If encryption is not required, send the original message.
mcabber/mcabber/otr.c
--- 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);