[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ruqola] /: Fix autotest
From:       Laurent Montel <null () kde ! org>
Date:       2018-05-31 18:39:46
Message-ID: E1fOSUE-0003Pt-5e () code ! kde ! org
[Download RAW message or body]

Git commit 8e9ee507ec7b2e3c37412bd1a9720240753cb620 by Laurent Montel.
Committed on 31/05/2018 at 18:39.
Pushed by mlaurent into branch 'master'.

Fix autotest

M  +1    -2    autotests/markroomasunreadjobtest.cpp
M  +20   -0    src/restapi/restapirequest.cpp
M  +2    -0    src/restapi/restapirequest.h
M  +2    -2    src/restapi/subscriptions/markroomasunreadjob.cpp

https://commits.kde.org/ruqola/8e9ee507ec7b2e3c37412bd1a9720240753cb620

diff --git a/autotests/markroomasunreadjobtest.cpp b/autotests/markroomasunreadjobtest.cpp
index 05a2ae6..d88e246 100644
--- a/autotests/markroomasunreadjobtest.cpp
+++ b/autotests/markroomasunreadjobtest.cpp
@@ -55,9 +55,8 @@ void MarkRoomAsUnReadJobTest::shouldGenerateJson()
     job.setObjectId(roomId);
     job.setUnReadObject(MarkRoomAsUnReadJob::Room);
     QCOMPARE(job.json().toJson(QJsonDocument::Compact), \
                QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1());
-    //TODO add messageid
     job.setUnReadObject(MarkRoomAsUnReadJob::FromMessage);
-    QCOMPARE(job.json().toJson(QJsonDocument::Compact), \
QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1()); +    \
QCOMPARE(job.json().toJson(QJsonDocument::Compact), \
QStringLiteral("{\"firstUnreadMessage\":{\"_id\":\"foo1\"}}").arg(roomId).toLatin1());  }
 
 void MarkRoomAsUnReadJobTest::shouldNotStarting()
diff --git a/src/restapi/restapirequest.cpp b/src/restapi/restapirequest.cpp
index 91ea836..587ef32 100644
--- a/src/restapi/restapirequest.cpp
+++ b/src/restapi/restapirequest.cpp
@@ -72,6 +72,7 @@
 #include "directmessage/createdmjob.h"
 
 #include "subscriptions/markroomasreadjob.h"
+#include "subscriptions/markroomasunreadjob.h"
 
 #include <QNetworkAccessManager>
 #include <QNetworkReply>
@@ -564,6 +565,25 @@ void RestApiRequest::markAsRead(const QString &roomId)
     job->start();
 }
 
+void RestApiRequest::markRoomAsUnRead(const QString &roomId)
+{
+    MarkRoomAsUnReadJob *job = new MarkRoomAsUnReadJob(this);
+    job->setObjectId(roomId);
+    job->setUnReadObject(MarkRoomAsUnReadJob::Room);
+    initializeRestApiJob(job);
+    job->start();
+}
+
+void RestApiRequest::markMessageAsUnReadFrom(const QString &messageId)
+{
+    MarkRoomAsUnReadJob *job = new MarkRoomAsUnReadJob(this);
+    job->setObjectId(messageId);
+    job->setUnReadObject(MarkRoomAsUnReadJob::FromMessage);
+    initializeRestApiJob(job);
+    job->start();
+}
+
+
 void RestApiRequest::getRooms()
 {
     GetRoomsJob *job = new GetRoomsJob(this);
diff --git a/src/restapi/restapirequest.h b/src/restapi/restapirequest.h
index dd417e1..ae7d48a 100644
--- a/src/restapi/restapirequest.h
+++ b/src/restapi/restapirequest.h
@@ -102,6 +102,8 @@ public:
     void mobilePushNotifications(const QString &roomId, const QString &value);
     void unreadAlert(const QString &roomId, const QString &value);
     void setAvatar(const QString &avatarUrl);
+    void markRoomAsUnRead(const QString &roomId);
+    void markMessageAsUnReadFrom(const QString &messageId);
 Q_SIGNALS:
     void avatar(const QString &userId, const QString &url);
     void logoutDone();
diff --git a/src/restapi/subscriptions/markroomasunreadjob.cpp \
b/src/restapi/subscriptions/markroomasunreadjob.cpp index 1a939a4..1516451 100644
--- a/src/restapi/subscriptions/markroomasunreadjob.cpp
+++ b/src/restapi/subscriptions/markroomasunreadjob.cpp
@@ -124,9 +124,9 @@ QNetworkRequest MarkRoomAsUnReadJob::request() const
 QJsonDocument MarkRoomAsUnReadJob::json() const
 {
     QJsonObject jsonObj;
-    if (mObjectId == Room) {
+    if (mUnReadObject == Room) {
         jsonObj[QLatin1String("roomId")] = mObjectId;
-    } else if (mObjectId == FromMessage) {
+    } else if (mUnReadObject == FromMessage) {
         QJsonObject fromMessage;
         fromMessage[QLatin1String("_id")] = mObjectId;
         jsonObj[QLatin1String("firstUnreadMessage")] = fromMessage;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic