aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/notifications.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-08-03 17:29:52 +0900
committerGitHub <noreply@github.com>2019-08-03 17:29:52 +0900
commit66e116b7b1e848e80577a0229c8995db0a54932e (patch)
tree763340439a0f4034e9c829d76cb1ffe9766b83c5 /lib/csapi/notifications.cpp
parent5b236dfe895c7766002559570aa29c9033009228 (diff)
parentc05ade838f0fce81f2bbe80a3295618a8a26ff52 (diff)
downloadlibquotient-66e116b7b1e848e80577a0229c8995db0a54932e.tar.gz
libquotient-66e116b7b1e848e80577a0229c8995db0a54932e.zip
Merge pull request #295 from marcdeop/140_impose_coding_standard
140 impose coding standard
Diffstat (limited to 'lib/csapi/notifications.cpp')
-rw-r--r--lib/csapi/notifications.cpp70
1 files changed, 38 insertions, 32 deletions
diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp
index 5d3bdb47..3a05a0b2 100644
--- a/lib/csapi/notifications.cpp
+++ b/lib/csapi/notifications.cpp
@@ -12,32 +12,36 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
+// Converters
namespace QMatrixClient
{
- // Converters
- template <> struct JsonObjectConverter<GetNotificationsJob::Notification>
+template <>
+struct JsonObjectConverter<GetNotificationsJob::Notification>
+{
+ static void fillFrom(const QJsonObject& jo,
+ GetNotificationsJob::Notification& result)
{
- static void fillFrom(const QJsonObject& jo, GetNotificationsJob::Notification& result)
- {
- fromJson(jo.value("actions"_ls), result.actions);
- fromJson(jo.value("event"_ls), result.event);
- fromJson(jo.value("profile_tag"_ls), result.profileTag);
- fromJson(jo.value("read"_ls), result.read);
- fromJson(jo.value("room_id"_ls), result.roomId);
- fromJson(jo.value("ts"_ls), result.ts);
- }
- };
+ fromJson(jo.value("actions"_ls), result.actions);
+ fromJson(jo.value("event"_ls), result.event);
+ fromJson(jo.value("profile_tag"_ls), result.profileTag);
+ fromJson(jo.value("read"_ls), result.read);
+ fromJson(jo.value("room_id"_ls), result.roomId);
+ fromJson(jo.value("ts"_ls), result.ts);
+ }
+};
+
} // namespace QMatrixClient
class GetNotificationsJob::Private
{
- public:
- QString nextToken;
- std::vector<Notification> notifications;
+public:
+ QString nextToken;
+ std::vector<Notification> notifications;
};
-BaseJob::Query queryToGetNotifications(const QString& from, Omittable<int> limit, const QString& only)
+BaseJob::Query queryToGetNotifications(const QString& from,
+ Omittable<int> limit, const QString& only)
{
BaseJob::Query _q;
addParam<IfNotEmpty>(_q, QStringLiteral("from"), from);
@@ -46,31 +50,33 @@ BaseJob::Query queryToGetNotifications(const QString& from, Omittable<int> limit
return _q;
}
-QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable<int> limit, const QString& only)
+QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from,
+ Omittable<int> limit,
+ const QString& only)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/notifications",
- queryToGetNotifications(from, limit, only));
+ basePath % "/notifications",
+ queryToGetNotifications(from, limit, only));
}
-static const auto GetNotificationsJobName = QStringLiteral("GetNotificationsJob");
+static const auto GetNotificationsJobName =
+ QStringLiteral("GetNotificationsJob");
-GetNotificationsJob::GetNotificationsJob(const QString& from, Omittable<int> limit, const QString& only)
+GetNotificationsJob::GetNotificationsJob(const QString& from,
+ Omittable<int> limit,
+ const QString& only)
: BaseJob(HttpVerb::Get, GetNotificationsJobName,
- basePath % "/notifications",
- queryToGetNotifications(from, limit, only))
+ basePath % "/notifications",
+ queryToGetNotifications(from, limit, only))
, d(new Private)
-{
-}
+{}
GetNotificationsJob::~GetNotificationsJob() = default;
-const QString& GetNotificationsJob::nextToken() const
-{
- return d->nextToken;
-}
+const QString& GetNotificationsJob::nextToken() const { return d->nextToken; }
-std::vector<GetNotificationsJob::Notification>&& GetNotificationsJob::notifications()
+std::vector<GetNotificationsJob::Notification>&&
+GetNotificationsJob::notifications()
{
return std::move(d->notifications);
}
@@ -81,8 +87,8 @@ BaseJob::Status GetNotificationsJob::parseJson(const QJsonDocument& data)
fromJson(json.value("next_token"_ls), d->nextToken);
if (!json.contains("notifications"_ls))
return { IncorrectResponse,
- "The key 'notifications' not found in the response" };
+ "The key 'notifications' not found in the response" };
fromJson(json.value("notifications"_ls), d->notifications);
+
return Success;
}
-