diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-19 19:23:10 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-07 12:30:37 +0900 |
commit | e88627976488b0b6eea6da3389eefb860980d661 (patch) | |
tree | c5972d761fc43b6a29b86a495722d309ccf80b65 /jobs/generated/profile.cpp | |
parent | 70d9ca7b870e35109dfdbe9ab3c63ba094a75379 (diff) | |
download | libquotient-e88627976488b0b6eea6da3389eefb860980d661.tar.gz libquotient-e88627976488b0b6eea6da3389eefb860980d661.zip |
Generated jobs: Don't dump empty strings to body parameters
This is important for (soon to be added) LoginJob, since the server is
sensitive to getting an (even empty) entity for "medium" as opposed to
omitting it entirely. This cannot be addressed on the spec level; on the
other hand, removing empty parameters from the payload reduces useless
bytes getting on the wire.
Diffstat (limited to 'jobs/generated/profile.cpp')
-rw-r--r-- | jobs/generated/profile.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/jobs/generated/profile.cpp b/jobs/generated/profile.cpp index 201bca79..f24db15a 100644 --- a/jobs/generated/profile.cpp +++ b/jobs/generated/profile.cpp @@ -15,12 +15,14 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); SetDisplayNameJob::SetDisplayNameJob(QString userId, QString displayname) : BaseJob(HttpVerb::Put, "SetDisplayNameJob", basePath % "/profile/" % userId % "/displayname", - Query { }, - Data { - { "displayname", toJson(displayname) } - } + Query { } ) -{ } +{ + Data _data; + if (!displayname.isEmpty()) + _data.insert("displayname", toJson(displayname)); + setRequestData(_data); +} class GetDisplayNameJob::Private { @@ -32,8 +34,7 @@ class GetDisplayNameJob::Private GetDisplayNameJob::GetDisplayNameJob(QString userId) : BaseJob(HttpVerb::Get, "GetDisplayNameJob", basePath % "/profile/" % userId % "/displayname", - Query { }, - Data { } + Query { }, Data { }, false ), d(new Private) { } @@ -59,12 +60,14 @@ BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data) SetAvatarUrlJob::SetAvatarUrlJob(QString userId, QString avatar_url) : BaseJob(HttpVerb::Put, "SetAvatarUrlJob", basePath % "/profile/" % userId % "/avatar_url", - Query { }, - Data { - { "avatar_url", toJson(avatar_url) } - } + Query { } ) -{ } +{ + Data _data; + if (!avatar_url.isEmpty()) + _data.insert("avatar_url", toJson(avatar_url)); + setRequestData(_data); +} class GetAvatarUrlJob::Private { @@ -76,8 +79,7 @@ class GetAvatarUrlJob::Private GetAvatarUrlJob::GetAvatarUrlJob(QString userId) : BaseJob(HttpVerb::Get, "GetAvatarUrlJob", basePath % "/profile/" % userId % "/avatar_url", - Query { }, - Data { } + Query { }, Data { }, false ), d(new Private) { } @@ -111,8 +113,7 @@ class GetUserProfileJob::Private GetUserProfileJob::GetUserProfileJob(QString userId) : BaseJob(HttpVerb::Get, "GetUserProfileJob", basePath % "/profile/" % userId, - Query { }, - Data { } + Query { }, Data { }, false ), d(new Private) { } |