0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-16 15:00:51 +01:00

modules/console: Fix unwrapped prev event iteration.

ircd:Ⓜ️:v1: Fix unwrapped prev event reference.
This commit is contained in:
Jason Volk 2019-07-10 07:38:19 -07:00
parent 114b997088
commit 1b65cc36c8
2 changed files with 25 additions and 45 deletions

View file

@ -1569,20 +1569,15 @@ ircd::m::v1::fetch_head(const id::room &room_id,
proto.at("event") proto.at("event")
}; };
const json::array prev_events const m::event::prev prev
{ {
event.at("prev_events") event
};
const json::array prev_event
{
prev_events.at(0)
}; };
const auto &prev_event_id const auto &prev_event_id
{ {
prev_event.at(0) prev.prev_event(0)
}; };
return unquote(prev_event_id); return prev_event_id;
} }

View file

@ -11623,46 +11623,31 @@ console_cmd__fed__head(opt &out, const string_view &line)
proto["event"] proto["event"]
}; };
const m::event::prev prev{event};
for(size_t i(0); i < prev.auth_events_count(); ++i)
{
const m::event::id &id
{
prev.auth_event(i)
};
out << "AUTH " << id << " " << std::endl;
}
for(size_t i(0); i < prev.prev_events_count(); ++i)
{
const m::event::id &id
{
prev.prev_event(i)
};
out << "PREV " << id << " " << std::endl;
}
out << "DEPTH " out << "DEPTH "
<< event["depth"] << event["depth"]
<< std::endl; << std::endl;
const json::array &prev_events
{
event["prev_events"]
};
for(const json::array &prev_event : prev_events)
{
const m::event::id &id
{
unquote(prev_event.at(0))
};
out << "PREV "
<< id << " "
<< string_view{prev_event.at(1)}
<< std::endl;
}
const json::array &auth_events
{
event["auth_events"]
};
for(const json::array &auth_event : auth_events)
{
const m::event::id &id
{
unquote(auth_event.at(0))
};
out << "AUTH "
<< id << " "
<< string_view{auth_event.at(1)}
<< std::endl;
}
return true; return true;
} }