diff options
-rw-r--r-- | lib/csapi/content-repo.cpp | 9 | ||||
-rw-r--r-- | lib/csapi/event_context.cpp | 3 | ||||
-rw-r--r-- | lib/csapi/gtad.yaml | 2 | ||||
-rw-r--r-- | lib/csapi/list_public_rooms.cpp | 3 | ||||
-rw-r--r-- | lib/csapi/message_pagination.cpp | 3 | ||||
-rw-r--r-- | lib/csapi/notifications.cpp | 3 | ||||
-rw-r--r-- | lib/csapi/{{base}}.cpp.mustache | 4 |
7 files changed, 18 insertions, 9 deletions
diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 101f0ee9..d0efdb9e 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -159,8 +159,10 @@ class GetContentThumbnailJob::Private BaseJob::Query queryToGetContentThumbnail(Omittable<int> width, Omittable<int> height, const QString& method) { BaseJob::Query _q; - _q.addQueryItem("width", QString("%1").arg(width)); - _q.addQueryItem("height", QString("%1").arg(height)); + if (width) + _q.addQueryItem("width", QString("%1").arg(width.value())); + if (height) + _q.addQueryItem("height", QString("%1").arg(height.value())); if (!method.isEmpty()) _q.addQueryItem("method", method); return _q; @@ -213,7 +215,8 @@ BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable<qint64> ts) { BaseJob::Query _q; _q.addQueryItem("url", url); - _q.addQueryItem("ts", QString("%1").arg(ts)); + if (ts) + _q.addQueryItem("ts", QString("%1").arg(ts.value())); return _q; } diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index c7e01391..97494062 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -26,7 +26,8 @@ class GetEventContextJob::Private BaseJob::Query queryToGetEventContext(Omittable<int> limit) { BaseJob::Query _q; - _q.addQueryItem("limit", QString("%1").arg(limit)); + if (limit) + _q.addQueryItem("limit", QString("%1").arg(limit.value())); return _q; } diff --git a/lib/csapi/gtad.yaml b/lib/csapi/gtad.yaml index d1bee0e6..b83e489b 100644 --- a/lib/csapi/gtad.yaml +++ b/lib/csapi/gtad.yaml @@ -121,7 +121,7 @@ mustache: joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}' joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}' passQueryParams: '{{#queryParams}}{{paramName}}{{#@join}}, {{/@join}}{{/queryParams}}' - paramToString: '{{#isString}}{{nameCamelCase}}{{/isString}}{{^isString}}QString("%1").arg({{nameCamelCase}}){{/isString}}' + paramToString: '{{#isString}}{{nameCamelCase}}{{/isString}}{{^isString}}QString("%1").arg({{nameCamelCase}}{{^required?}}{{#useOmittable}}.value(){{/useOmittable}}{{/required?}}){{/isString}}' # preamble: preamble.mustache copyrightName: Kitsune Ral copyrightEmail: <kitsune-ral@users.sf.net> diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 97beba1c..f104786b 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -100,7 +100,8 @@ class GetPublicRoomsJob::Private BaseJob::Query queryToGetPublicRooms(Omittable<int> limit, const QString& since, const QString& server) { BaseJob::Query _q; - _q.addQueryItem("limit", QString("%1").arg(limit)); + if (limit) + _q.addQueryItem("limit", QString("%1").arg(limit.value())); if (!since.isEmpty()) _q.addQueryItem("since", since); if (!server.isEmpty()) diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index 1ea852de..d23dd911 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -27,7 +27,8 @@ BaseJob::Query queryToGetRoomEvents(const QString& from, const QString& to, cons if (!to.isEmpty()) _q.addQueryItem("to", to); _q.addQueryItem("dir", dir); - _q.addQueryItem("limit", QString("%1").arg(limit)); + if (limit) + _q.addQueryItem("limit", QString("%1").arg(limit.value())); if (!filter.isEmpty()) _q.addQueryItem("filter", filter); return _q; diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index 4c77d760..9bff072b 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -52,7 +52,8 @@ BaseJob::Query queryToGetNotifications(const QString& from, Omittable<int> limit BaseJob::Query _q; if (!from.isEmpty()) _q.addQueryItem("from", from); - _q.addQueryItem("limit", QString("%1").arg(limit)); + if (limit) + _q.addQueryItem("limit", QString("%1").arg(limit.value())); if (!only.isEmpty()) _q.addQueryItem("only", only); return _q; diff --git a/lib/csapi/{{base}}.cpp.mustache b/lib/csapi/{{base}}.cpp.mustache index f555761f..8a7dd3b0 100644 --- a/lib/csapi/{{base}}.cpp.mustache +++ b/lib/csapi/{{base}}.cpp.mustache @@ -62,7 +62,9 @@ BaseJob::Query queryTo{{camelCaseOperationId}}({{#queryParams}}{{>joinedParamDef { BaseJob::Query _q;{{#queryParams}} {{^required?}}{{#isString}} if (!{{nameCamelCase}}.isEmpty()) - {{/isString}}{{/required?}} _q.addQueryItem("{{baseName}}", {{>paramToString}});{{/queryParams}} + {{/isString}}{{! +}}{{#useOmittable}} if ({{nameCamelCase}}) + {{/useOmittable}}{{/required?}} _q.addQueryItem("{{baseName}}", {{>paramToString}});{{/queryParams}} return _q; } {{/queryParams?}}{{^bodyParams}} |