From 3affda8b13644ffcfa0aa7e763bac7c4863968fb Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Tue, 8 Nov 2022 15:08:52 +0100 Subject: [PATCH] Add offers to the response regardless of it being empty (#389) Fixes #351 --- src/rpc/handlers/Subscribe.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/rpc/handlers/Subscribe.cpp b/src/rpc/handlers/Subscribe.cpp index cdeae6b8e..096ba36ce 100644 --- a/src/rpc/handlers/Subscribe.cpp +++ b/src/rpc/handlers/Subscribe.cpp @@ -340,7 +340,8 @@ doSubscribe(Context const& context) } std::vector books; - boost::json::array snapshot; + boost::json::object response; + if (request.contains(JS(books))) { auto parsed = @@ -351,10 +352,9 @@ doSubscribe(Context const& context) std::get, boost::json::array>>( parsed); books = std::move(bks); - snapshot = std::move(snap); + response[JS(offers)] = std::move(snap); } - boost::json::object response; if (request.contains(JS(streams))) response = subscribeToStreams( context.yield, request, context.session, *context.subscriptions); @@ -369,8 +369,6 @@ doSubscribe(Context const& context) if (request.contains(JS(books))) subscribeToBooks(books, context.session, *context.subscriptions); - if (snapshot.size()) - response[JS(offers)] = snapshot; return response; }