[network/ruqola] src/rocketchatrestapi-qt: Fix json

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit ec6948f204bc44a5b3c8b1eee7d07ea8cd4a339b by Laurent Montel.
Committed on 21/07/2026 at 11:59.
Pushed by mlaurent into branch 'master'.

Fix json

M  +19   -17   src/rocketchatrestapi-qt/autotests/roomscleanhistoryjobtest.cpp
M  +5    -16   src/rocketchatrestapi-qt/rooms/roomscleanhistoryjob.cpp

https://invent.kde.org/network/ruqola/-/commit/ec6948f204bc44a5b3c8b1eee7d07ea8cd4a339b

diff --git a/src/rocketchatrestapi-qt/autotests/roomscleanhistoryjobtest.cpp b/src/rocketchatrestapi-qt/autotests/roomscleanhistoryjobtest.cpp
index 4d1be5bb90..bc20fd68cf 100644
--- a/src/rocketchatrestapi-qt/autotests/roomscleanhistoryjobtest.cpp
+++ b/src/rocketchatrestapi-qt/autotests/roomscleanhistoryjobtest.cpp
@@ -60,38 +60,40 @@ void RoomsCleanHistoryJobTest::shouldGenerateJson()
     info.latest = QDateTime(QDate(2020, 12, 3), QTime(5, 7, 50));
     info.oldest = QDateTime(QDate(2020, 3, 3), QTime(5, 7, 50));
     job.setCleanHistoryInfo(info);
-    QCOMPARE(
-        job.json().toJson(QJsonDocument::Compact),
-        QStringLiteral(R"({"latest":"2020-12-03T05:07:50.000","oldest":"2020-03-03T05:07:50.000","roomId":"%1"})").arg(QLatin1StringView(roomId)).toLatin1());
+    QCOMPARE(job.json().toJson(QJsonDocument::Compact),
+             QStringLiteral("{\"excludePinned\":false,\"filesOnly\":false,\"ignoreDiscussion\":false,\"ignoreThreads\":false,\"inclusive\":false,\"latest\":"
+                            "\"2020-12-03T05:07:50.000\",\"oldest\":\"2020-03-03T05:07:50.000\",\"roomId\":\"%1\"}")
+                 .arg(QLatin1StringView(roomId))
+                 .toLatin1());
     info.inclusive = true;
     job.setCleanHistoryInfo(info);
     QCOMPARE(job.json().toJson(QJsonDocument::Compact),
-             QStringLiteral(R"({"inclusive":true,"latest":"2020-12-03T05:07:50.000","oldest":"2020-03-03T05:07:50.000","roomId":"%1"})")
+             QStringLiteral("{\"excludePinned\":false,\"filesOnly\":false,\"ignoreDiscussion\":false,\"ignoreThreads\":false,\"inclusive\":true,\"latest\":"
+                            "\"2020-12-03T05:07:50.000\",\"oldest\":\"2020-03-03T05:07:50.000\",\"roomId\":\"%1\"}")
                  .arg(QLatin1StringView(roomId))
                  .toLatin1());
     info.ignoreThreads = true;
     job.setCleanHistoryInfo(info);
     QCOMPARE(job.json().toJson(QJsonDocument::Compact),
-             QStringLiteral(R"({"ignoreThreads":true,"inclusive":true,"latest":"2020-12-03T05:07:50.000","oldest":"2020-03-03T05:07:50.000","roomId":"%1"})")
+             QStringLiteral("{\"excludePinned\":false,\"filesOnly\":false,\"ignoreDiscussion\":false,\"ignoreThreads\":true,\"inclusive\":true,\"latest\":"
+                            "\"2020-12-03T05:07:50.000\",\"oldest\":\"2020-03-03T05:07:50.000\",\"roomId\":\"%1\"}")
                  .arg(QLatin1StringView(roomId))
                  .toLatin1());
     const QStringList users = {u"bla"_s, u"bli"_s};
     info.users = users;
     job.setCleanHistoryInfo(info);
-    QCOMPARE(
-        job.json().toJson(QJsonDocument::Compact),
-        QStringLiteral(
-            R"({"ignoreThreads":true,"inclusive":true,"latest":"2020-12-03T05:07:50.000","oldest":"2020-03-03T05:07:50.000","roomId":"%1","users":["bla","bli"]})")
-            .arg(QLatin1StringView(roomId))
-            .toLatin1());
+    QCOMPARE(job.json().toJson(QJsonDocument::Compact),
+             QStringLiteral("{\"excludePinned\":false,\"filesOnly\":false,\"ignoreDiscussion\":false,\"ignoreThreads\":true,\"inclusive\":true,\"latest\":"
+                            "\"2020-12-03T05:07:50.000\",\"oldest\":\"2020-03-03T05:07:50.000\",\"roomId\":\"%1\",\"users\":[\"bla\",\"bli\"]}")
+                 .arg(QLatin1StringView(roomId))
+                 .toLatin1());
     info.ignoreDiscussion = true;
     job.setCleanHistoryInfo(info);
-    QCOMPARE(
-        job.json().toJson(QJsonDocument::Compact),
-        QStringLiteral(
-            R"({"ignoreDiscussion":true,"ignoreThreads":true,"inclusive":true,"latest":"2020-12-03T05:07:50.000","oldest":"2020-03-03T05:07:50.000","roomId":"%1","users":["bla","bli"]})")
-            .arg(QLatin1StringView(roomId))
-            .toLatin1());
+    QCOMPARE(job.json().toJson(QJsonDocument::Compact),
+             QStringLiteral("{\"excludePinned\":false,\"filesOnly\":false,\"ignoreDiscussion\":true,\"ignoreThreads\":true,\"inclusive\":true,\"latest\":"
+                            "\"2020-12-03T05:07:50.000\",\"oldest\":\"2020-03-03T05:07:50.000\",\"roomId\":\"%1\",\"users\":[\"bla\",\"bli\"]}")
+                 .arg(QLatin1StringView(roomId))
+                 .toLatin1());
 }
 
 void RoomsCleanHistoryJobTest::shouldNotStarting()
diff --git a/src/rocketchatrestapi-qt/rooms/roomscleanhistoryjob.cpp b/src/rocketchatrestapi-qt/rooms/roomscleanhistoryjob.cpp
index 4ed47de709..a59a82f840 100644
--- a/src/rocketchatrestapi-qt/rooms/roomscleanhistoryjob.cpp
+++ b/src/rocketchatrestapi-qt/rooms/roomscleanhistoryjob.cpp
@@ -79,22 +79,11 @@ QJsonDocument RoomsCleanHistoryJob::json() const
 {
     QJsonObject jsonObj;
     jsonObj["roomId"_L1] = QLatin1StringView(mCleanHistoryInfo.roomId);
-    if (mCleanHistoryInfo.inclusive) {
-        jsonObj["inclusive"_L1] = true;
-    }
-    if (mCleanHistoryInfo.ignoreThreads) {
-        jsonObj["ignoreThreads"_L1] = true;
-    }
-    if (mCleanHistoryInfo.filesOnly) {
-        jsonObj["filesOnly"_L1] = true;
-    }
-    if (mCleanHistoryInfo.excludePinned) {
-        jsonObj["excludePinned"_L1] = true;
-    }
-    if (mCleanHistoryInfo.ignoreDiscussion) {
-        jsonObj["ignoreDiscussion"_L1] = true;
-    }
-
+    jsonObj["inclusive"_L1] = mCleanHistoryInfo.inclusive;
+    jsonObj["ignoreThreads"_L1] = mCleanHistoryInfo.ignoreThreads;
+    jsonObj["filesOnly"_L1] = mCleanHistoryInfo.filesOnly;
+    jsonObj["excludePinned"_L1] = mCleanHistoryInfo.excludePinned;
+    jsonObj["ignoreDiscussion"_L1] = mCleanHistoryInfo.ignoreDiscussion;
     jsonObj["latest"_L1] = mCleanHistoryInfo.latest.toString(Qt::ISODateWithMs);
     jsonObj["oldest"_L1] = mCleanHistoryInfo.oldest.toString(Qt::ISODateWithMs);
     if (!mCleanHistoryInfo.users.isEmpty()) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.