diff options
author | Black Hat <bhat@encom.eu.org> | 2019-09-26 22:22:36 -0700 |
---|---|---|
committer | Black Hat <bhat@encom.eu.org> | 2019-09-26 22:22:36 -0700 |
commit | 363cf452bcdbaf6ff1cf94a83ca66cbb31122346 (patch) | |
tree | c64c8fda885e4e1785130e8ee3e7c47fd18cbf67 /lib/csapi/users.cpp | |
parent | 412e2cf19449e73aa7da729e9c5de6502687aade (diff) | |
parent | 944653463fe4134c82d85e2d01e2bc0fa43fd727 (diff) | |
download | libquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.tar.gz libquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.zip |
Merge branch 'master' of https://github.com/quotient-im/libQuotient into
bhat-libqtolm-update
Diffstat (limited to 'lib/csapi/users.cpp')
-rw-r--r-- | lib/csapi/users.cpp | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 0d867145..77c297dd 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -8,37 +8,42 @@ #include <QtCore/QStringBuilder> -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -namespace QMatrixClient +// Converters +namespace Quotient { - // Converters - template <> struct JsonObjectConverter<SearchUserDirectoryJob::User> +template <> +struct JsonObjectConverter<SearchUserDirectoryJob::User> +{ + static void fillFrom(const QJsonObject& jo, + SearchUserDirectoryJob::User& result) { - static void fillFrom(const QJsonObject& jo, SearchUserDirectoryJob::User& result) - { - fromJson(jo.value("user_id"_ls), result.userId); - fromJson(jo.value("display_name"_ls), result.displayName); - fromJson(jo.value("avatar_url"_ls), result.avatarUrl); - } - }; -} // namespace QMatrixClient + fromJson(jo.value("user_id"_ls), result.userId); + fromJson(jo.value("display_name"_ls), result.displayName); + fromJson(jo.value("avatar_url"_ls), result.avatarUrl); + } +}; + +} // namespace Quotient class SearchUserDirectoryJob::Private { - public: - QVector<User> results; - bool limited; +public: + QVector<User> results; + bool limited; }; -static const auto SearchUserDirectoryJobName = QStringLiteral("SearchUserDirectoryJob"); +static const auto SearchUserDirectoryJobName = + QStringLiteral("SearchUserDirectoryJob"); -SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable<int> limit) +SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, + Omittable<int> limit) : BaseJob(HttpVerb::Post, SearchUserDirectoryJobName, - basePath % "/user_directory/search") + basePath % "/user_directory/search") , d(new Private) { QJsonObject _data; @@ -54,22 +59,19 @@ const QVector<SearchUserDirectoryJob::User>& SearchUserDirectoryJob::results() c return d->results; } -bool SearchUserDirectoryJob::limited() const -{ - return d->limited; -} +bool SearchUserDirectoryJob::limited() const { return d->limited; } BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data) { auto json = data.object(); if (!json.contains("results"_ls)) return { IncorrectResponse, - "The key 'results' not found in the response" }; + "The key 'results' not found in the response" }; fromJson(json.value("results"_ls), d->results); if (!json.contains("limited"_ls)) return { IncorrectResponse, - "The key 'limited' not found in the response" }; + "The key 'limited' not found in the response" }; fromJson(json.value("limited"_ls), d->limited); + return Success; } - |