[network/ruqola] src/rocketchatrestapi-qt: Add fetchuserswaitingforgroupkey
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit e68dd018de93a086c2145b61f3c1739b300712fa by Laurent Montel. Committed on 03/08/2026 at 17:45. Pushed by mlaurent into branch 'master'. Add fetchuserswaitingforgroupkey A +42 -0 src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.cpp [License: LGPL(v2.0+)] A +20 -0 src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.h [License: LGPL(v2.0+)] A +62 -0 src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.cpp [License: LGPL(v2.0+)] A +32 -0 src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.h [License: LGPL(v2.0+)] https://invent.kde.org/network/ruqola/-/commit/e68dd018de93a086c2145b61f3c1739b300712fa diff --git a/src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.cpp b/src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.cpp new file mode 100644 index 0000000000..e62e908413 --- /dev/null +++ b/src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.cpp @@ -0,0 +1,42 @@ +/* + SPDX-FileCopyrightText: 2026 Laurent Montel <[email protected]> + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#include "fetchuserswaitingforgroupkeyjobtest.h" + +#include "e2e/fetchuserswaitingforgroupkeyjob.h" +#include "restapimethod.h" +#include <QTest> + +QTEST_GUILESS_MAIN(FetchUsersWaitingForGroupKeyJobTest) +using namespace Qt::Literals::StringLiterals; +using namespace RocketChatRestApi; +FetchUsersWaitingForGroupKeyJobTest::FetchUsersWaitingForGroupKeyJobTest(QObject *parent) + : QObject(parent) +{ +} + +void FetchUsersWaitingForGroupKeyJobTest::shouldHaveDefaultValue() +{ + FetchUsersWaitingForGroupKeyJob job; + QVERIFY(!job.restApiMethod()); + QVERIFY(!job.networkAccessManager()); + QVERIFY(!job.start()); + QVERIFY(job.requireHttpAuthentication()); + QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); +} + +void FetchUsersWaitingForGroupKeyJobTest::shouldGenerateRequest() +{ + FetchUsersWaitingForGroupKeyJob job; + RestApiMethod method; + method.setServerUrl(u"http://www.kde.org"_s); + job.setRestApiMethod(&method); + const QNetworkRequest request = job.request(); + QCOMPARE(request.url(), QUrl(u"http://www.kde.org/api/v1/e2e.fetchUsersWaitingForGroupKey"_s)); +} + +#include "moc_fetchuserswaitingforgroupkeyjobtest.cpp" diff --git a/src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.h b/src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.h new file mode 100644 index 0000000000..a56671b763 --- /dev/null +++ b/src/rocketchatrestapi-qt/autotests/fetchuserswaitingforgroupkeyjobtest.h @@ -0,0 +1,20 @@ +/* + SPDX-FileCopyrightText: 2026 Laurent Montel <[email protected]> + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#pragma once + +#include <QObject> + +class FetchUsersWaitingForGroupKeyJobTest : public QObject +{ + Q_OBJECT +public: + explicit FetchUsersWaitingForGroupKeyJobTest(QObject *parent = nullptr); + ~FetchUsersWaitingForGroupKeyJobTest() override = default; +private Q_SLOTS: + void shouldHaveDefaultValue(); + void shouldGenerateRequest(); +}; diff --git a/src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.cpp b/src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.cpp new file mode 100644 index 0000000000..d84ef88abb --- /dev/null +++ b/src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.cpp @@ -0,0 +1,62 @@ +/* + SPDX-FileCopyrightText: 2026 Laurent Montel <[email protected]> + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#include "fetchuserswaitingforgroupkeyjob.h" + +#include "restapimethod.h" +#include <QJsonDocument> +#include <QJsonObject> +#include <QNetworkRequest> + +using namespace Qt::Literals::StringLiterals; +using namespace RocketChatRestApi; +FetchUsersWaitingForGroupKeyJob::FetchUsersWaitingForGroupKeyJob(QObject *parent) + : RestApiAbstractJob(parent) +{ +} + +FetchUsersWaitingForGroupKeyJob::~FetchUsersWaitingForGroupKeyJob() = default; + +bool FetchUsersWaitingForGroupKeyJob::start() +{ + if (!canStart()) { + deleteLater(); + return false; + } + submitGetRequest(); + + addStartRestApiInfo("Start FetchUsersWaitingForGroupKeyJob"); + + return true; +} + +void FetchUsersWaitingForGroupKeyJob::onGetRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) +{ + const QJsonObject replyObject = replyJson.object(); + + if (replyObject["success"_L1].toBool()) { + addLoggerInfo("FetchUsersWaitingForGroupKeyJob: success: "_ba + replyJson.toJson(QJsonDocument::Indented)); + Q_EMIT fetchUsersWaitingForGroupKeyDone(replyObject); + } else { + emitFailedMessage(replyErrorString, replyObject); + addLoggerWarning("FetchUsersWaitingForGroupKeyJob: problem: "_ba + replyJson.toJson(QJsonDocument::Indented)); + } +} + +QNetworkRequest FetchUsersWaitingForGroupKeyJob::request() const +{ + const QUrl url = mRestApiMethod->generateUrl(RestApiUtil::RestApiUrlType::E2EFetchUsersWaitingForGroupKey); + QNetworkRequest request(url); + addAuthRawHeader(request); + return request; +} + +bool FetchUsersWaitingForGroupKeyJob::requireHttpAuthentication() const +{ + return true; +} + +#include "moc_fetchuserswaitingforgroupkeyjob.cpp" diff --git a/src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.h b/src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.h new file mode 100644 index 0000000000..9662c85d42 --- /dev/null +++ b/src/rocketchatrestapi-qt/e2e/fetchuserswaitingforgroupkeyjob.h @@ -0,0 +1,32 @@ +/* + SPDX-FileCopyrightText: 2026 Laurent Montel <[email protected]> + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#pragma once + +#include "librocketchatrestapi-qt_export.h" +#include "restapiabstractjob.h" + +namespace RocketChatRestApi +{ +class LIBROCKETCHATRESTAPI_QT_EXPORT FetchUsersWaitingForGroupKeyJob : public RestApiAbstractJob +{ + Q_OBJECT +public: + explicit FetchUsersWaitingForGroupKeyJob(QObject *parent = nullptr); + ~FetchUsersWaitingForGroupKeyJob() override; + + [[nodiscard]] bool start() override; + [[nodiscard]] bool requireHttpAuthentication() const override; + + [[nodiscard]] QNetworkRequest request() const override; + +Q_SIGNALS: + void fetchUsersWaitingForGroupKeyDone(const QJsonObject &replyObject); + +private: + LIBROCKETCHATRESTAPI_QT_NO_EXPORT void onGetRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) override; +}; +}