mirror of
https://github.com/matrix-construct/construct
synced 2025-02-27 22:20:15 +01:00
ircd:Ⓜ️:event::append: Minor cleanup; reduce density of branches.
This commit is contained in:
parent
b3323c3f8d
commit
049ac86564
1 changed files with 28 additions and 18 deletions
|
@ -154,7 +154,12 @@ ircd::m::event::append::append(json::stack::object &object,
|
||||||
return false;
|
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
|
const m::user::ignores ignores
|
||||||
{
|
{
|
||||||
|
@ -181,6 +186,28 @@ ircd::m::event::append::append(json::stack::object &object,
|
||||||
object, "event_id", event.event_id
|
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
|
// Get the list of properties to send to the client so we can strip
|
||||||
// the remaining and save b/w
|
// the remaining and save b/w
|
||||||
// TODO: m::filter
|
// TODO: m::filter
|
||||||
|
@ -214,23 +241,6 @@ ircd::m::event::append::append(json::stack::object &object,
|
||||||
return true;
|
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_
|
json::stack::object unsigned_
|
||||||
{
|
{
|
||||||
object, "unsigned"
|
object, "unsigned"
|
||||||
|
|
Loading…
Add table
Reference in a new issue