From c349b37f60739bda416741d364d1bea1b8ba7e90 Mon Sep 17 00:00:00 2001 From: LDA Date: Thu, 11 Jul 2024 00:43:44 +0200 Subject: [PATCH] [FIX] Fix statuses --- src/AS.c | 3 +-- src/XMPPThread.c | 50 +++++++++++++++++++++++------------------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/AS.c b/src/AS.c index 2010d8f..4a08878 100644 --- a/src/AS.c +++ b/src/AS.c @@ -678,7 +678,6 @@ ASUpload(const ParseeConfig *c, Stream *from, unsigned int size, char *mime) { JsonEncode(reply, StreamStdout(), JSON_PRETTY); StreamFlush(StreamStdout()); - Log(LOG_INFO, "Less obvious upload fail"); } HttpClientContextFree(ctx); JsonFree(reply); @@ -953,7 +952,7 @@ ASSetStatus(const ParseeConfig *c, char *user, UserStatus status, char *msg) HashMap *request; char *path; char *status_str = NULL; - if (!c || !user || !msg) + if (!c || !user) { return; } diff --git a/src/XMPPThread.c b/src/XMPPThread.c index 07e598c..a167759 100644 --- a/src/XMPPThread.c +++ b/src/XMPPThread.c @@ -1160,31 +1160,6 @@ PresenceStanza(ParseeData *args, XMLElement *stanza) XMLElement *status = XMLookForUnique(stanza, "status"); char *oid = HashMapGet(stanza->attrs, "from"); - if (status) - { - XMLElement *status_data = ArrayGet(status->children, 0); - char *decode_from = ParseeLookupJID(oid); - char *from_matrix = ParseeDecodeMXID(decode_from); - if (!from_matrix || *from_matrix != '@') - { - Free(from_matrix); - from_matrix = ParseeEncodeJID(args->config, decode_from, false); - } - if (status_data) - { - char *status_str = status_data->data; - - /* TODO: Verify whenever this code works as soon as I can get - * my own instance (kappach.at) with presence enabled. */ - ASSetStatus( - args->config, from_matrix, - GuessStatus(stanza), status_str - ); - } - - Free(decode_from); - Free(from_matrix); - } if ((user_info = XMLookForTKV(stanza, "x", "xmlns", MUC_USER_NS))) { XMLElement *item = XMLookForUnique(user_info, "item"); @@ -1296,6 +1271,29 @@ PresenceStanza(ParseeData *args, XMLElement *stanza) Free(parsee); Free(room); } + if (status) + { + XMLElement *status_data = ArrayGet(status->children, 0); + char *decode_from = ParseeLookupJID(oid); + char *trimmed = ParseeTrimJID(decode_from); + char *from_matrix = ParseeEncodeJID(args->config, trimmed, false); + char *status_str = NULL; + if (status_data) + { + status_str = status_data->data; + } + + /* TODO: Verify whenever this code works as soon as I can get + * my own instance (kappach.at) with presence enabled. */ + ASSetStatus( + args->config, from_matrix, + GuessStatus(stanza), status_str + ); + + Free(decode_from); + Free(from_matrix); + Free(trimmed); + } if (vc) { XMLElement *photo = XMLookForUnique(vc, "photo"); @@ -1459,7 +1457,7 @@ ParseeXMPPThread(void *argp) pthread_mutex_init(&info.lock, NULL); /* TODO: Make that configurable. */ - info.available_dispatchers = 8; + info.available_dispatchers = 16; info.dispatchers = Malloc( sizeof(*info.dispatchers) * info.available_dispatchers );