From 253731268d1b68a17bb19acf873be991f286a1d6 Mon Sep 17 00:00:00 2001 From: LDA Date: Thu, 1 Aug 2024 22:50:32 +0200 Subject: [PATCH] [MOD] Do not quit on corpseless stanzas. Reactions seems to suffer from that problem... --- src/XMPPThread/Stanzas/Message.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/XMPPThread/Stanzas/Message.c b/src/XMPPThread/Stanzas/Message.c index 9a90af1..847c37a 100644 --- a/src/XMPPThread/Stanzas/Message.c +++ b/src/XMPPThread/Stanzas/Message.c @@ -126,17 +126,12 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr) } #undef CHAT_STATES - if (!body) - { - XMLFreeElement(stanza); - return false; - } to = ParseeDecodeMXID(HashMapGet(stanza->attrs, "to")); decode_from = ParseeLookupJID(from); from_matrix = ParseeEncodeJID(args->config, decode_from, true); room = ParseeFindDMRoom(args, to, from); - data = ArrayGet(body->children, 0); + data = body ? ArrayGet(body->children, 0) : NULL; /* TODO: CLEAN THAT UP */ mroom_id = ParseeGetBridgedRoom(args, stanza); @@ -219,12 +214,13 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr) ASInvite(args->config, mroom_id, encoded); Free(ASJoin(args->config, mroom_id, encoded)); - /* Check if it is a media link */ - oob = XMLookForTKV(stanza, "x", "xmlns", "jabber:x:oob"); reactions = XMLookForTKV(stanza, "reactions", "xmlns", "urn:xmpp:reactions:0" ); - if (oob) + + /* Check if it is a media link */ + oob = XMLookForTKV(stanza, "x", "xmlns", "jabber:x:oob"); + if (oob && data) { char *mxc, *mime = NULL; HashMap *content = NULL; @@ -286,7 +282,7 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr) Free(event_id); event_id = NULL; } - else + else if (data) { /* TODO: Use HTML-formatted bodies, and respect the fallback * trims the stanza provides us if possible. Element does not @@ -311,7 +307,7 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr) Free(event_id); pthread_mutex_unlock(&thr->info->chk_lock); } - else if (replaced) + else if (replaced && data) { event_id = ParseeGetEventFromID(args, stanza, replaced); Free(ASSend(