0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd:Ⓜ️:room::power: Simplify level_event / level_state interface related.

This commit is contained in:
Jason Volk 2018-10-27 14:27:53 -07:00
parent 4a1df6af85
commit 0ea1ba2968
2 changed files with 12 additions and 6 deletions

View file

@ -441,9 +441,14 @@ struct ircd::m::room::power
size_t count_levels() const;
// This suite queries with full defaulting logic as per the spec. These
// always return suitable results.
// always return suitable results. When determining power to change a state
// event rather than a non-state event, the state_key must always be
// defined. If the state_key is a default constructed string_view{} (which
// means !defined(state_key) and is not the same as string_view{""} for
// the common state_key="") then the interface considers your query for
// a non-state event rather than a state_event. Be careful.
int64_t level(const string_view &prop) const;
int64_t level_state(const string_view &type, const string_view &state_key = {}) const;
int64_t level_event(const string_view &type, const string_view &state_key) const;
int64_t level_event(const string_view &type) const;
int64_t level_user(const m::id::user &) const;

View file

@ -2060,10 +2060,8 @@ const
const auto &required_level
{
prop == "events" && defined(state_key)?
level_state(type, state_key):
prop == "events"?
level_event(type):
level_event(type, state_key):
level(prop)
};
@ -2144,10 +2142,13 @@ catch(const json::error &e)
}
int64_t
ircd::m::room::power::level_state(const string_view &type,
ircd::m::room::power::level_event(const string_view &type,
const string_view &state_key)
const try
{
if(!defined(state_key))
return level_event(type);
int64_t ret
{
default_power_level