From aa6b8352da711b131cc64987d46520dc5405326d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 3 Mar 2019 14:45:18 -0800 Subject: [PATCH] modules/federation/query: Respond with full profile when no field query parameter. --- modules/federation/query.cc | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/modules/federation/query.cc b/modules/federation/query.cc index 27a2c279e..844a71b4c 100644 --- a/modules/federation/query.cc +++ b/modules/federation/query.cc @@ -85,8 +85,7 @@ get__query_profile(client &client, const string_view field { - //TODO: XXX full profile aggregation w/ user:: linkage - request.query.at("field") + request.query["field"] }; const m::user user @@ -99,19 +98,50 @@ get__query_profile(client &client, user }; - profile.get(field, [&client] - (const string_view &field, const string_view &value) + if(!empty(field)) { - resource::response + profile.get(field, [&client] + (const string_view &field, const string_view &value) { - client, json::members + resource::response { - { field, value } - } + client, json::members + { + { field, value } + } + }; + }); + + return {}; + } + + resource::response::chunked response + { + client, http::OK + }; + + json::stack out + { + response.buf, response.flusher() + }; + + json::stack::object top + { + out + }; + + profile.for_each([&top] + (const string_view &key, const string_view &val) + { + json::stack::member + { + top, key, val }; + + return true; }); - return {}; // responded from closure + return response; } resource::response