aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/administrative_contact.cpp
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/administrative_contact.cpp
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/csapi/administrative_contact.cpp')
-rw-r--r--lib/csapi/administrative_contact.cpp192
1 files changed, 60 insertions, 132 deletions
diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp
index 11385dff..fa4f475a 100644
--- a/lib/csapi/administrative_contact.cpp
+++ b/lib/csapi/administrative_contact.cpp
@@ -4,172 +4,100 @@
#include "administrative_contact.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-namespace QMatrixClient
-{
- // Converters
-
- template <> struct JsonObjectConverter<GetAccount3PIDsJob::ThirdPartyIdentifier>
- {
- static void fillFrom(const QJsonObject& jo, GetAccount3PIDsJob::ThirdPartyIdentifier& result)
- {
- fromJson(jo.value("medium"_ls), result.medium);
- fromJson(jo.value("address"_ls), result.address);
- fromJson(jo.value("validated_at"_ls), result.validatedAt);
- fromJson(jo.value("added_at"_ls), result.addedAt);
- }
- };
-} // namespace QMatrixClient
-
-class GetAccount3PIDsJob::Private
-{
- public:
- QVector<ThirdPartyIdentifier> threepids;
-};
+using namespace Quotient;
QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/account/3pid");
+ QStringLiteral("/_matrix/client/r0")
+ % "/account/3pid");
}
-static const auto GetAccount3PIDsJobName = QStringLiteral("GetAccount3PIDsJob");
-
GetAccount3PIDsJob::GetAccount3PIDsJob()
- : BaseJob(HttpVerb::Get, GetAccount3PIDsJobName,
- basePath % "/account/3pid")
- , d(new Private)
-{
-}
-
-GetAccount3PIDsJob::~GetAccount3PIDsJob() = default;
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetAccount3PIDsJob"),
+ QStringLiteral("/_matrix/client/r0") % "/account/3pid")
+{}
-const QVector<GetAccount3PIDsJob::ThirdPartyIdentifier>& GetAccount3PIDsJob::threepids() const
-{
- return d->threepids;
-}
-
-BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- fromJson(json.value("threepids"_ls), d->threepids);
- return Success;
-}
-
-namespace QMatrixClient
-{
- // Converters
-
- template <> struct JsonObjectConverter<Post3PIDsJob::ThreePidCredentials>
- {
- static void dumpTo(QJsonObject& jo, const Post3PIDsJob::ThreePidCredentials& pod)
- {
- addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret);
- addParam<>(jo, QStringLiteral("id_server"), pod.idServer);
- addParam<>(jo, QStringLiteral("sid"), pod.sid);
- }
- };
-} // namespace QMatrixClient
-
-static const auto Post3PIDsJobName = QStringLiteral("Post3PIDsJob");
-
-Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, Omittable<bool> bind)
- : BaseJob(HttpVerb::Post, Post3PIDsJobName,
- basePath % "/account/3pid")
+Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds)
+ : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"),
+ QStringLiteral("/_matrix/client/r0") % "/account/3pid")
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds);
- addParam<IfNotEmpty>(_data, QStringLiteral("bind"), bind);
- setRequestData(_data);
+ setRequestData(std::move(_data));
}
-static const auto Delete3pidFromAccountJobName = QStringLiteral("Delete3pidFromAccountJob");
-
-Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const QString& address)
- : BaseJob(HttpVerb::Post, Delete3pidFromAccountJobName,
- basePath % "/account/3pid/delete")
+Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid,
+ const Omittable<AuthenticationData>& auth)
+ : BaseJob(HttpVerb::Post, QStringLiteral("Add3PIDJob"),
+ QStringLiteral("/_matrix/client/r0") % "/account/3pid/add")
{
QJsonObject _data;
- addParam<>(_data, QStringLiteral("medium"), medium);
- addParam<>(_data, QStringLiteral("address"), address);
- setRequestData(_data);
+ addParam<IfNotEmpty>(_data, QStringLiteral("auth"), auth);
+ addParam<>(_data, QStringLiteral("client_secret"), clientSecret);
+ addParam<>(_data, QStringLiteral("sid"), sid);
+ setRequestData(std::move(_data));
}
-class RequestTokenTo3PIDEmailJob::Private
-{
- public:
- Sid data;
-};
-
-static const auto RequestTokenTo3PIDEmailJobName = QStringLiteral("RequestTokenTo3PIDEmailJob");
-
-RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob(const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink)
- : BaseJob(HttpVerb::Post, RequestTokenTo3PIDEmailJobName,
- basePath % "/account/3pid/email/requestToken", false)
- , d(new Private)
+Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer,
+ const QString& idAccessToken, const QString& sid)
+ : BaseJob(HttpVerb::Post, QStringLiteral("Bind3PIDJob"),
+ QStringLiteral("/_matrix/client/r0") % "/account/3pid/bind")
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("client_secret"), clientSecret);
- addParam<>(_data, QStringLiteral("email"), email);
- addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt);
- addParam<IfNotEmpty>(_data, QStringLiteral("next_link"), nextLink);
addParam<>(_data, QStringLiteral("id_server"), idServer);
- setRequestData(_data);
+ addParam<>(_data, QStringLiteral("id_access_token"), idAccessToken);
+ addParam<>(_data, QStringLiteral("sid"), sid);
+ setRequestData(std::move(_data));
}
-RequestTokenTo3PIDEmailJob::~RequestTokenTo3PIDEmailJob() = default;
-
-const Sid& RequestTokenTo3PIDEmailJob::data() const
+Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium,
+ const QString& address,
+ const QString& idServer)
+ : BaseJob(HttpVerb::Post, QStringLiteral("Delete3pidFromAccountJob"),
+ QStringLiteral("/_matrix/client/r0") % "/account/3pid/delete")
{
- return d->data;
-}
-
-BaseJob::Status RequestTokenTo3PIDEmailJob::parseJson(const QJsonDocument& data)
-{
- fromJson(data, d->data);
- return Success;
+ QJsonObject _data;
+ addParam<IfNotEmpty>(_data, QStringLiteral("id_server"), idServer);
+ addParam<>(_data, QStringLiteral("medium"), medium);
+ addParam<>(_data, QStringLiteral("address"), address);
+ setRequestData(std::move(_data));
+ addExpectedKey("id_server_unbind_result");
}
-class RequestTokenTo3PIDMSISDNJob::Private
-{
- public:
- Sid data;
-};
-
-static const auto RequestTokenTo3PIDMSISDNJobName = QStringLiteral("RequestTokenTo3PIDMSISDNJob");
-
-RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob(const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink)
- : BaseJob(HttpVerb::Post, RequestTokenTo3PIDMSISDNJobName,
- basePath % "/account/3pid/msisdn/requestToken", false)
- , d(new Private)
+Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium,
+ const QString& address,
+ const QString& idServer)
+ : BaseJob(HttpVerb::Post, QStringLiteral("Unbind3pidFromAccountJob"),
+ QStringLiteral("/_matrix/client/r0") % "/account/3pid/unbind")
{
QJsonObject _data;
- addParam<>(_data, QStringLiteral("client_secret"), clientSecret);
- addParam<>(_data, QStringLiteral("country"), country);
- addParam<>(_data, QStringLiteral("phone_number"), phoneNumber);
- addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt);
- addParam<IfNotEmpty>(_data, QStringLiteral("next_link"), nextLink);
- addParam<>(_data, QStringLiteral("id_server"), idServer);
- setRequestData(_data);
+ addParam<IfNotEmpty>(_data, QStringLiteral("id_server"), idServer);
+ addParam<>(_data, QStringLiteral("medium"), medium);
+ addParam<>(_data, QStringLiteral("address"), address);
+ setRequestData(std::move(_data));
+ addExpectedKey("id_server_unbind_result");
}
-RequestTokenTo3PIDMSISDNJob::~RequestTokenTo3PIDMSISDNJob() = default;
-
-const Sid& RequestTokenTo3PIDMSISDNJob::data() const
+RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob(
+ const EmailValidationData& body)
+ : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDEmailJob"),
+ QStringLiteral("/_matrix/client/r0")
+ % "/account/3pid/email/requestToken",
+ false)
{
- return d->data;
+ setRequestData(Data(toJson(body)));
}
-BaseJob::Status RequestTokenTo3PIDMSISDNJob::parseJson(const QJsonDocument& data)
+RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob(
+ const MsisdnValidationData& body)
+ : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDMSISDNJob"),
+ QStringLiteral("/_matrix/client/r0")
+ % "/account/3pid/msisdn/requestToken",
+ false)
{
- fromJson(data, d->data);
- return Success;
+ setRequestData(Data(toJson(body)));
}
-