diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-04 21:34:00 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-04 21:34:00 +0900 |
commit | 6a9de91752dfe75e185bf90ab856367b2c804582 (patch) | |
tree | 2a12ecc84bf0055e317ef2e4aeec3439d92b2035 /lib/csapi/users.cpp | |
parent | d5397fe5ae2ca34d5cfb11394dac17728a2b50ce (diff) | |
parent | 5d1dd53890611376873f6f959e206d5a56cfff70 (diff) | |
download | libquotient-6a9de91752dfe75e185bf90ab856367b2c804582.tar.gz libquotient-6a9de91752dfe75e185bf90ab856367b2c804582.zip |
Merge branch 'kitsune-events-rewritten'
Diffstat (limited to 'lib/csapi/users.cpp')
-rw-r--r-- | lib/csapi/users.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index e7f68bda..408a8cad 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -23,11 +23,11 @@ namespace QMatrixClient const auto& _json = jv.toObject(); SearchUserDirectoryJob::User result; result.userId = - fromJson<QString>(_json.value("user_id")); + fromJson<QString>(_json.value("user_id"_ls)); result.displayName = - fromJson<QString>(_json.value("display_name")); + fromJson<QString>(_json.value("display_name"_ls)); result.avatarUrl = - fromJson<QString>(_json.value("avatar_url")); + fromJson<QString>(_json.value("avatar_url"_ls)); return result; } @@ -41,14 +41,16 @@ class SearchUserDirectoryJob::Private bool limited; }; +static const auto SearchUserDirectoryJobName = QStringLiteral("SearchUserDirectoryJob"); + SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable<int> limit) - : BaseJob(HttpVerb::Post, "SearchUserDirectoryJob", + : BaseJob(HttpVerb::Post, SearchUserDirectoryJobName, basePath % "/user_directory/search") , d(new Private) { QJsonObject _data; - addParam<>(_data, "search_term", searchTerm); - addParam<IfNotEmpty>(_data, "limit", limit); + addParam<>(_data, QStringLiteral("search_term"), searchTerm); + addParam<IfNotEmpty>(_data, QStringLiteral("limit"), limit); setRequestData(_data); } @@ -67,14 +69,14 @@ bool SearchUserDirectoryJob::limited() const BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("results")) + if (!json.contains("results"_ls)) return { JsonParseError, "The key 'results' not found in the response" }; - d->results = fromJson<QVector<User>>(json.value("results")); - if (!json.contains("limited")) + d->results = fromJson<QVector<User>>(json.value("results"_ls)); + if (!json.contains("limited"_ls)) return { JsonParseError, "The key 'limited' not found in the response" }; - d->limited = fromJson<bool>(json.value("limited")); + d->limited = fromJson<bool>(json.value("limited"_ls)); return Success; } |