From 9099eea04ffdf9dc624a30ff8efa55b006a306d7 Mon Sep 17 00:00:00 2001 From: jenli669 Date: Sat, 3 Aug 2019 00:09:05 +0200 Subject: [PATCH 1/2] fix(groups): remove logic that blocks parseConferenceSendMessageError --- src/core/core.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index af4128665..d104cebd7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -723,9 +723,8 @@ void Core::sendGroupMessageWithType(int groupId, const QString& message, Tox_Mes ToxString cMsg(message); Tox_Err_Conference_Send_Message error; - bool ok = - tox_conference_send_message(tox.get(), groupId, type, cMsg.data(), cMsg.size(), &error); - if (!ok || !parseConferenceSendMessageError(error)) { + tox_conference_send_message(tox.get(), groupId, type, cMsg.data(), cMsg.size(), &error); + if (!parseConferenceSendMessageError(error)) { emit groupSentFailed(groupId); return; } From 6c77d57da8cd35e46251e9835d2edc9c9737197f Mon Sep 17 00:00:00 2001 From: jenli669 Date: Sat, 3 Aug 2019 00:43:49 +0200 Subject: [PATCH 2/2] fix(groups): reduce group message size limit by 50 This commit fixes errors when sending large group messages stemming from inconsistencies in reported/true max message size in c-toxcore Fixes #5760 --- src/core/core.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index d104cebd7..2fbe1a39b 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -1450,7 +1450,17 @@ QStringList Core::splitMessage(const QString& message) QStringList splittedMsgs; QByteArray ba_message{message.toUtf8()}; - const auto maxLen = tox_max_message_length(); + /* + * TODO: Remove this hack; the reported max message length we receive from c-toxcore + * as of 08-02-2019 is inaccurate, causing us to generate too large messages when splitting + * them up. + * + * The inconsistency lies in c-toxcore group.c:2480 using MAX_GROUP_MESSAGE_DATA_LEN to verify + * message size is within limit, but tox_max_message_length giving a different size limit to us. + * + * (uint32_t tox_max_message_length(void); declared in tox.h, unable to see explicit definition) + */ + const auto maxLen = tox_max_message_length() - 50; while (ba_message.size() > maxLen) { int splitPos = ba_message.lastIndexOf('\n', maxLen - 1);