From 37df82363c800b8d6b2b172a486e395e4132e061 Mon Sep 17 00:00:00 2001
From: Joseph Donofry <joedonofry@gmail.com>
Date: Tue, 16 Jul 2019 18:06:09 -0400
Subject: [PATCH] Add 'from' and 'only' params to notifications endpoint

---
 include/mtxclient/http/client.hpp |  5 ++++-
 lib/http/client.cpp               | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/include/mtxclient/http/client.hpp b/include/mtxclient/http/client.hpp
index 00376a25d..49fb9b944 100644
--- a/include/mtxclient/http/client.hpp
+++ b/include/mtxclient/http/client.hpp
@@ -167,7 +167,10 @@ public:
 
         //! Paginate through the list of events that the user has been,
         //! or would have been notified about.
-        void notifications(uint64_t limit, Callback<mtx::responses::Notifications> cb);
+        void notifications(uint64_t limit,
+                           const std::string &from,
+                           const std::string &only,
+                           Callback<mtx::responses::Notifications> cb);
 
         //! Perform logout.
         void logout(Callback<mtx::responses::Logout> cb);
diff --git a/lib/http/client.cpp b/lib/http/client.cpp
index 23e877630..f7ced1b59 100644
--- a/lib/http/client.cpp
+++ b/lib/http/client.cpp
@@ -151,11 +151,22 @@ Client::logout(Callback<mtx::responses::Logout> callback)
 }
 
 void
-Client::notifications(uint64_t limit, Callback<mtx::responses::Notifications> cb)
+Client::notifications(uint64_t limit,
+                      const std::string &from,
+                      const std::string &only,
+                      Callback<mtx::responses::Notifications> cb)
 {
         std::map<std::string, std::string> params;
         params.emplace("limit", std::to_string(limit));
 
+        if (!from.empty()) {
+                params.emplace("from", from);
+        }
+
+        if (!only.empty()) {
+                params.emplace("only", only);
+        }
+
         get<mtx::responses::Notifications>(
           "/client/r0/notifications?" + mtx::client::utils::query_params(params),
           [cb](const mtx::responses::Notifications &res, HeaderFields, RequestErr err) {
-- 
GitLab