0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-25 05:18:23 +02:00

ircd:Ⓜ️:event::append: Minor cleanup; reduce density of branches.

This commit is contained in:
Jason Volk 2019-09-17 15:26:40 -07:00
parent b3323c3f8d
commit 049ac86564

View file

@ -154,7 +154,12 @@ ircd::m::event::append::append(json::stack::object &object,
return false;
}
if(has_user && !is_state && *opts.user_id != json::get<"sender"_>(event))
const bool check_ignores
{
has_user && !is_state
};
if(check_ignores && *opts.user_id != json::get<"sender"_>(event))
{
const m::user::ignores ignores
{
@ -181,6 +186,28 @@ ircd::m::event::append::append(json::stack::object &object,
object, "event_id", event.event_id
};
const bool query_prev_state
{
has_event_idx && opts.query_prev_state && is_state
};
if(query_prev_state)
{
const auto prev_idx
{
room::state::prev(*opts.event_idx)
};
m::get(std::nothrow, prev_idx, "content", [&object]
(const json::object &content)
{
json::stack::member
{
object, "prev_content", content
};
});
}
// Get the list of properties to send to the client so we can strip
// the remaining and save b/w
// TODO: m::filter
@ -214,23 +241,6 @@ ircd::m::event::append::append(json::stack::object &object,
return true;
});
if(has_event_idx && opts.query_prev_state && is_state)
{
const auto prev_idx
{
room::state::prev(*opts.event_idx)
};
m::get(std::nothrow, prev_idx, "content", [&object]
(const json::object &content)
{
json::stack::member
{
object, "prev_content", content
};
});
}
json::stack::object unsigned_
{
object, "unsigned"