From 7151792b8c354bd8388e70da9e4b14c79f565695 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 2 Aug 2015 01:12:54 +0100 Subject: [PATCH] Handle private messages that include muc#user namespace --- src/xmpp/message.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 5105a1d3..ada2d260 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -746,9 +746,17 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con // ignore handled namespaces xmpp_stanza_t *conf = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); - xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); xmpp_stanza_t *captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA); - if (conf || mucuser || captcha) { + if (conf || captcha) { + return 1; + } + + // some clients send the mucuser namespace with private messages + // if the namespace exists, and the stanza contains a body element, assume its a private message + // otherwise exit the handler + xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); + if (mucuser && body == NULL) { return 1; } @@ -764,7 +772,6 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con // standard chat message, use jid without resource GDateTime *timestamp = stanza_get_delay(stanza); - xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); if (body) { char *message = xmpp_stanza_get_text(body); if (message) {