0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-24 14:34:00 +01:00

modules/client/rooms/relations: Respond with newest relations first. (fixes #170)

This commit is contained in:
Jason Volk 2022-08-17 16:16:09 -07:00
parent c010920f7c
commit 5eebfbbb90

View file

@ -16,7 +16,7 @@ static void
relations_chunk_append(client &client,
const m::resource::request &request,
const m::event::idx &event_idx,
const m::event &event,
m::event::fetch &event,
json::stack::array &chunk);
static void
@ -133,18 +133,13 @@ try
};
m::event::fetch event;
relates.for_each(rel_type, [&client, &request, &event, &chunk]
relates.rfor_each(rel_type, [&client, &request, &event, &chunk]
(const m::event::idx &event_idx, const json::object &, const m::relates_to &)
{
if(unlikely(!seek(std::nothrow, event, event_idx)))
return true;
relations_chunk_append(client, request, event_idx, event, chunk);
return true;
});
if(likely(seek(std::nothrow, event, event_idx)))
relations_chunk_append(client, request, event_idx, event, chunk);
relations_chunk_append(client, request, event_idx, event, chunk);
}
catch(const std::exception &e)
{
@ -163,10 +158,13 @@ void
relations_chunk_append(client &client,
const m::resource::request &request,
const m::event::idx &event_idx,
const m::event &event,
m::event::fetch &event,
json::stack::array &chunk)
{
if(unlikely(!seek(std::nothrow, event, event_idx)))
return;
if(!visible(event, request.user_id))
return;