mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
modules/federation: Add auth_chain to state and state_ids response.
This commit is contained in:
parent
73f57f70a3
commit
6a6d190a02
2 changed files with 64 additions and 22 deletions
|
@ -73,21 +73,41 @@ get__state(client &client,
|
|||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
json::stack::member pdus_m
|
||||
{
|
||||
top, "pdus"
|
||||
};
|
||||
|
||||
json::stack::array pdus
|
||||
// pdus
|
||||
{
|
||||
pdus_m
|
||||
};
|
||||
json::stack::array pdus
|
||||
{
|
||||
top, "pdus"
|
||||
};
|
||||
|
||||
state.for_each([&pdus]
|
||||
(const m::event &event)
|
||||
state.for_each([&pdus]
|
||||
(const m::event &event)
|
||||
{
|
||||
pdus.append(event);
|
||||
});
|
||||
}
|
||||
|
||||
// auth_chain
|
||||
{
|
||||
pdus.append(event);
|
||||
});
|
||||
json::stack::array auth_chain
|
||||
{
|
||||
top, "auth_chain"
|
||||
};
|
||||
|
||||
const m::event::auth::chain ac
|
||||
{
|
||||
m::index(event_id)
|
||||
};
|
||||
|
||||
m::event::fetch event;
|
||||
ac.for_each([&auth_chain, &event]
|
||||
(const m::event::idx &event_idx)
|
||||
{
|
||||
if(seek(event, event_idx, std::nothrow))
|
||||
auth_chain.append(event);
|
||||
});
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -66,21 +66,43 @@ get__state_ids(client &client,
|
|||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
json::stack::member pdus_m
|
||||
{
|
||||
top, "pdu_ids"
|
||||
};
|
||||
|
||||
json::stack::array pdus
|
||||
// pdu_ids
|
||||
{
|
||||
pdus_m
|
||||
};
|
||||
json::stack::array pdu_ids
|
||||
{
|
||||
top, "pdu_ids"
|
||||
};
|
||||
|
||||
state.for_each(m::event::id::closure{[&pdus]
|
||||
(const m::event::id &event_id)
|
||||
state.for_each(m::event::id::closure{[&pdu_ids]
|
||||
(const m::event::id &event_id)
|
||||
{
|
||||
pdu_ids.append(event_id);
|
||||
}});
|
||||
}
|
||||
|
||||
// auth_chain
|
||||
{
|
||||
pdus.append(event_id);
|
||||
}});
|
||||
json::stack::array auth_chain
|
||||
{
|
||||
top, "auth_chain"
|
||||
};
|
||||
|
||||
const m::event::auth::chain ac
|
||||
{
|
||||
m::index(event_id)
|
||||
};
|
||||
|
||||
ac.for_each([&auth_chain]
|
||||
(const m::event::idx &event_idx)
|
||||
{
|
||||
m::event_id(event_idx, std::nothrow, [&auth_chain]
|
||||
(const auto &event_id)
|
||||
{
|
||||
auth_chain.append(event_id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue