diff options
author | James Booth <boothj5@gmail.com> | 2015-08-02 01:12:54 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-08-02 01:12:54 +0100 |
commit | 7151792b8c354bd8388e70da9e4b14c79f565695 (patch) | |
tree | 485a0e4f2b278691574c10d8cfa71cc675f03149 /src/xmpp | |
parent | 41c93c33502e92583100010b2ca6cb61d1323cff (diff) | |
download | profani-tty-7151792b8c354bd8388e70da9e4b14c79f565695.tar.gz |
Handle private messages that include muc#user namespace
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/message.c | 13 |
1 files 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) { |