about summary refs log tree commit diff stats
path: root/src/xmpp/message.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp/message.c')
-rw-r--r--src/xmpp/message.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 28b126a6..8e057e99 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1239,17 +1239,10 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c
     }
     Jid* jid = jid_create(from);
 
-    Jid* to_jid = NULL;
-    const gchar* to = xmpp_stanza_get_to(stanza);
-    if (to) {
-        to_jid = jid_create(to);
-    }
-
     // private message from chat room use full jid (room/nick)
     if (muc_active(jid->barejid)) {
         _handle_muc_private_message(stanza);
         jid_destroy(jid);
-        jid_destroy(to_jid);
         return;
     }
 
@@ -1257,15 +1250,13 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c
     ProfMessage* message = message_init();
     message->is_mam = is_mam;
     message->from_jid = jid;
-    if (to_jid) {
-        message->to_jid = to_jid;
-    } else {
-        if (is_carbon) {
-            // happens when receive a carbon of a self sent message
-            // really? maybe some servers do this, but it's not required.
-            Jid* from_jid = jid_create(from);
-            message->to_jid = from_jid;
-        }
+    const gchar* to = xmpp_stanza_get_to(stanza);
+    if (to) {
+        message->to_jid = jid_create(to);
+    } else if (is_carbon) {
+        // happens when receive a carbon of a self sent message
+        // really? maybe some servers do this, but it's not required.
+        message->to_jid = jid_create(from);
     }
 
     if (mucuser) {
@@ -1274,11 +1265,6 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c
         message->type = PROF_MSG_TYPE_CHAT;
     }
 
-    const gchar* to_text = xmpp_stanza_get_to(stanza);
-    if (to_text) {
-        message->to_jid = jid_create(to_text);
-    }
-
     // message stanza id
     const char* id = xmpp_stanza_get_id(stanza);
     if (id) {