From 7433daa4405ffaec1ea64a25a15901d92405c165 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 31 Mar 2019 00:36:56 -0700 Subject: [PATCH] modules/client/rooms/context: Minor cleanup extra; remove default token inits. --- modules/client/rooms/context.cc | 45 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/modules/client/rooms/context.cc b/modules/client/rooms/context.cc index c5ed8d648..19bda3270 100644 --- a/modules/client/rooms/context.cc +++ b/modules/client/rooms/context.cc @@ -120,10 +120,13 @@ get__context(client &client, ret, "event", event }; - m::event::id::buf start{event_id}; + m::event::id::buf start; { - json::stack::member member{ret, "events_before"}; - json::stack::array array{member}; + json::stack::array array + { + ret, "events_before" + }; + m::room::messages before { room, event_id, &default_fetch_opts @@ -151,15 +154,19 @@ get__context(client &client, start = {}; } - json::stack::member - { - ret, "start", json::value{start} - }; + if(start) + json::stack::member + { + ret, "start", json::value{start} + }; - m::event::id::buf end{event_id}; + m::event::id::buf end; { - json::stack::member member{ret, "events_after"}; - json::stack::array array{member}; + json::stack::array array + { + ret, "events_after" + }; + m::room::messages after { room, event_id, &default_fetch_opts @@ -187,14 +194,18 @@ get__context(client &client, end = {}; } - json::stack::member - { - ret, "end", json::value{end} - }; + if(end) + json::stack::member + { + ret, "end", json::value{end} + }; { - json::stack::member member{ret, "state"}; - json::stack::array array{member}; + json::stack::array array + { + ret, "state" + }; + const m::room::state state { room, &default_fetch_opts @@ -218,7 +229,7 @@ get__context(client &client, }); } - return {}; + return response; } void