mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd:Ⓜ️:room::power: Add util to generate spec-default power_levels content.
This commit is contained in:
parent
c972683e2c
commit
bbaf38937b
3 changed files with 100 additions and 0 deletions
|
@ -76,4 +76,6 @@ struct ircd::m::room::power
|
|||
power(const m::room &, const event::idx &power_event_idx);
|
||||
power(const m::room &);
|
||||
power() = default;
|
||||
|
||||
static json::object default_content(const mutable_buffer &out, const m::id::user &creator);
|
||||
};
|
||||
|
|
|
@ -2174,6 +2174,24 @@ ircd::m::room::power::default_user_level
|
|||
0
|
||||
};
|
||||
|
||||
ircd::json::object
|
||||
ircd::m::room::power::default_content(const mutable_buffer &out,
|
||||
const m::user::id &creator)
|
||||
{
|
||||
using prototype = json::object (const mutable_buffer &, const m::user::id &);
|
||||
|
||||
static mods::import<prototype> call
|
||||
{
|
||||
"m_room", "ircd::m::room::power::default_content"
|
||||
};
|
||||
|
||||
return call(out, creator);
|
||||
}
|
||||
|
||||
//
|
||||
// room::power::power
|
||||
//
|
||||
|
||||
ircd::m::room::power::power(const m::room &room)
|
||||
:power
|
||||
{
|
||||
|
|
|
@ -88,6 +88,86 @@ ircd::m::count_since(const m::room &room,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ircd::json::object
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::power::default_content(const mutable_buffer &buf,
|
||||
const m::user::id &creator)
|
||||
{
|
||||
json::stack out{buf};
|
||||
json::stack::object content{out};
|
||||
|
||||
assert(default_power_level == 50);
|
||||
json::stack::member
|
||||
{
|
||||
content, "ban", json::value(default_power_level)
|
||||
};
|
||||
|
||||
json::stack::object
|
||||
{
|
||||
content, "events"
|
||||
};
|
||||
|
||||
assert(default_event_level == 0);
|
||||
json::stack::member
|
||||
{
|
||||
content, "events_default", json::value(default_event_level)
|
||||
};
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
content, "invite", json::value(default_power_level)
|
||||
};
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
content, "kick", json::value(default_power_level)
|
||||
};
|
||||
|
||||
{
|
||||
json::stack::object notifications
|
||||
{
|
||||
content, "notifications"
|
||||
};
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
notifications, "room", json::value(default_power_level)
|
||||
};
|
||||
}
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
content, "redact", json::value(default_power_level)
|
||||
};
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
content, "state_default", json::value(default_power_level)
|
||||
};
|
||||
|
||||
{
|
||||
json::stack::object users
|
||||
{
|
||||
content, "users"
|
||||
};
|
||||
|
||||
assert(default_creator_level == 100);
|
||||
json::stack::member
|
||||
{
|
||||
users, creator, json::value(default_creator_level)
|
||||
};
|
||||
}
|
||||
|
||||
assert(default_user_level == 0);
|
||||
json::stack::member
|
||||
{
|
||||
content, "users_default", json::value(default_user_level)
|
||||
};
|
||||
|
||||
content.~object();
|
||||
return json::object{out.completed()};
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::origins::random(const origins &origins,
|
||||
|
|
Loading…
Reference in a new issue