0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

ircd:Ⓜ️:room::head: Fix erroneous empty string result.

This commit is contained in:
Jason Volk 2020-11-30 00:48:04 -08:00
parent d49227c848
commit f80a31620c

View file

@ -65,12 +65,9 @@ try
}; };
// When the top_head option is given we query for that here // When the top_head option is given we query for that here
const auto top_head std::tuple<m::id::event::buf, int64_t, m::event::idx> top_head;
{ if(opts.need_top_head)
opts.need_top_head? top_head = m::top(std::nothrow, head.room.room_id);
m::top(std::nothrow, head.room.room_id):
std::tuple<m::id::event::buf, int64_t, m::event::idx>{}
};
// Iterate the room head; starts with oldest events // Iterate the room head; starts with oldest events
bool need_top_head{opts.need_top_head}; bool need_top_head{opts.need_top_head};
@ -132,14 +129,14 @@ try
// If the iteration did not provide us with the top_head and the opts // If the iteration did not provide us with the top_head and the opts
// require it, we add that here. // require it, we add that here.
if(need_top_head) if(need_top_head && std::get<0>(top_head))
{ {
assert(limit > 0); assert(limit > 0);
append(out, std::get<0>(top_head)); append(out, std::get<0>(top_head));
this->depth[1] = std::get<1>(top_head); this->depth[1] = std::get<1>(top_head);
need_top_head = false; need_top_head = false;
--limit; --limit;
if(need_my_head && event::my(std::get<event::idx>(top_head))) if(need_my_head && event::my(std::get<2>(top_head)))
need_my_head = false; need_my_head = false;
} }
@ -199,6 +196,7 @@ ircd::m::append_v1(json::stack::array &out,
}; };
// [0] // [0]
assert(event_id);
prev.append(event_id); prev.append(event_id);
// [1] // [1]
@ -217,6 +215,7 @@ void
ircd::m::append_v3(json::stack::array &out, ircd::m::append_v3(json::stack::array &out,
const event::id &event_id) const event::id &event_id)
{ {
assert(event_id);
out.append(event_id); out.append(event_id);
} }