mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
modules/federation/get_missing_events: Use static closure; replace unquote() w/ json::string.
This commit is contained in:
parent
e79c619ece
commit
0d4898b0cd
1 changed files with 14 additions and 9 deletions
|
@ -115,12 +115,13 @@ get__missing_events(client &client,
|
||||||
request["latest_events"]
|
request["latest_events"]
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto in_earliest{[&earliest](const auto &event_id)
|
static const auto in_array{[]
|
||||||
|
(const json::array &array, const auto &event_id)
|
||||||
{
|
{
|
||||||
return end(earliest) != std::find_if(begin(earliest), end(earliest), [&event_id]
|
return end(array) != std::find_if(begin(array), end(array), [&event_id]
|
||||||
(const auto &event_id_)
|
(const json::string &_event_id)
|
||||||
{
|
{
|
||||||
return event_id == unquote(event_id_);
|
return event_id == _event_id;
|
||||||
});
|
});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
@ -141,10 +142,10 @@ get__missing_events(client &client,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::deque<std::string> queue;
|
std::deque<std::string> queue;
|
||||||
const auto add_queue{[&limit, &queue, &in_earliest]
|
const auto add_queue{[&limit, &queue, &earliest]
|
||||||
(const m::event::id &event_id) -> bool
|
(const m::event::id &event_id) -> bool
|
||||||
{
|
{
|
||||||
if(in_earliest(event_id))
|
if(in_array(earliest, event_id))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(end(queue) != std::find(begin(queue), end(queue), event_id))
|
if(end(queue) != std::find(begin(queue), end(queue), event_id))
|
||||||
|
@ -157,13 +158,17 @@ get__missing_events(client &client,
|
||||||
return true;
|
return true;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
for(const auto &event_id : latest)
|
for(const json::string &event_id : latest)
|
||||||
add_queue(unquote(event_id));
|
add_queue(event_id);
|
||||||
|
|
||||||
m::event::fetch event;
|
m::event::fetch event;
|
||||||
while(!queue.empty())
|
while(!queue.empty())
|
||||||
{
|
{
|
||||||
const auto &event_id{queue.front()};
|
const auto &event_id
|
||||||
|
{
|
||||||
|
queue.front()
|
||||||
|
};
|
||||||
|
|
||||||
const unwind pop{[&queue]
|
const unwind pop{[&queue]
|
||||||
{
|
{
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
|
|
Loading…
Reference in a new issue