0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

modules/federation/event_auth: Return the spec event_auth.

This commit is contained in:
Jason Volk 2019-02-14 16:58:39 -08:00
parent 2660b30061
commit 23a04dee6a

View file

@ -59,9 +59,9 @@ get__event_auth(client &client,
url::decode(event_id, request.parv[1]) url::decode(event_id, request.parv[1])
}; };
const m::event::fetch event const m::event::idx event_idx
{ {
event_id m::index(event_id) // throws m::NOT_FOUND
}; };
const m::room room const m::room room
@ -75,11 +75,6 @@ get__event_auth(client &client,
"You are not permitted to view the room at this event" "You are not permitted to view the room at this event"
}; };
const m::room::state state
{
room
};
resource::response::chunked response resource::response::chunked response
{ {
client, http::OK client, http::OK
@ -101,25 +96,13 @@ get__event_auth(client &client,
auth_chain_m auth_chain_m
}; };
const auto append{[&auth_chain] m::event::auth::chain(event_idx).for_each([&auth_chain]
(const m::event &event) (const m::event::idx &event_idx, const m::event &event)
{ {
if(json::get<"event_id"_>(event)) auth_chain.append(event);
auth_chain.append(event); return true;
}}; });
const auto append_with_sender{[&append, &state, &event]
(const m::event &event_)
{
append(event_);
if(json::get<"sender"_>(event_) != json::get<"sender"_>(event))
state.get(std::nothrow, "m.room.member", json::get<"sender"_>(event_), append);
}};
state.get(std::nothrow, "m.room.create", "", append);
state.get(std::nothrow, "m.room.join_rules", "", append);
state.get(std::nothrow, "m.room.power_levels", "", append_with_sender);
state.get(std::nothrow, "m.room.member", json::get<"sender"_>(event), append);
return {}; return {};
} }