From b852809d0c554754496a54cadc7d14d3802bc183 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Wed, 28 Mar 2018 00:17:51 -0700 Subject: [PATCH] fix(history): don't save own messages when history is disabled Fix #5036 --- src/persistence/history.cpp | 4 ++++ src/widget/form/chatform.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/persistence/history.cpp b/src/persistence/history.cpp index 0bcf30083..df3b72780 100644 --- a/src/persistence/history.cpp +++ b/src/persistence/history.cpp @@ -230,6 +230,10 @@ void History::addNewMessage(const QString& friendPk, const QString& message, con const QDateTime& time, bool isSent, QString dispName, const std::function& insertIdCallback) { + if (!Settings::getInstance().getEnableLogging()) { + qWarning() << "Blocked a message from being added to database while history is disabled"; + return; + } if (!isValid()) { return; } diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 79e5000ae..6a42f2a8a 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -984,7 +984,7 @@ void ChatForm::SendMessageStr(QString msg) uint32_t friendId = f->getId(); int rec = isAction ? core->sendAction(friendId, part) : core->sendMessage(friendId, part); - if (history) { + if (history && Settings::getInstance().getEnableLogging()) { auto* offMsgEngine = getOfflineMsgEngine(); QString selfPk = Core::getInstance()->getSelfId().toString(); QString pk = f->getPublicKey().toString();