0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

modules/m_room_power_levels: Remove stale hooks.

modules/m_room_create: Remove stale hooks.
This commit is contained in:
Jason Volk 2019-07-15 16:47:08 -07:00
parent 76ed65d36e
commit 477fc25687
2 changed files with 0 additions and 161 deletions

View file

@ -16,79 +16,6 @@ IRCD_MODULE
"Matrix m.room.create"
};
static void
_can_create_room(const m::event &event,
m::vm::eval &eval)
{
const m::event::id &event_id
{
event.event_id
};
const m::room::id &room_id
{
at<"room_id"_>(event)
};
const m::user::id &sender
{
at<"sender"_>(event)
};
if(room_id.host() != sender.host())
throw m::ACCESS_DENIED
{
"Room on '%s' cannot be created by sender on '%s'",
room_id.host(),
sender.host()
};
if(room_id.host() != sender.host())
throw m::ACCESS_DENIED
{
"Room on '%s' cannot be created by event from '%s'",
room_id.host(),
sender.host()
};
if(room_id.host() != at<"origin"_>(event))
throw m::ACCESS_DENIED
{
"Room on '%s' cannot be created by event originating from '%s'",
room_id.host(),
at<"origin"_>(event)
};
const json::object &content
{
at<"content"_>(event)
};
// note: this is a purposely weak check of the content.creator field.
// This server accepts a missing content.creator field entirely because
// it considers the sender of the create event as the room creator.
// Nevertheless if the content.creator field was specified it must match
// the sender or we reject.
if(content.has("creator"))
if(unquote(content.at("creator")) != sender)
throw m::ACCESS_DENIED
{
"Room %s creator must be the sender %s",
string_view{room_id},
string_view{sender}
};
}
const m::hookfn<m::vm::eval &>
_can_create_room_hookfn
{
_can_create_room,
{
{ "_site", "vm.eval" },
{ "type", "m.room.create" },
}
};
static void
_created_room(const m::event &event,
m::vm::eval &)

View file

@ -16,94 +16,6 @@ IRCD_MODULE
"Matrix m.room.power_levels"
};
static void
_has_power(const m::event &event,
m::vm::eval &)
{
const auto &room_id
{
json::get<"room_id"_>(event)
};
const auto &event_id
{
event.event_id
};
if(!room_id || !event_id) // Not evaluated here
return;
const auto &type
{
at<"type"_>(event)
};
if(type == "m.room.create") // Checked by _can_create_room
return;
const m::room room
{
room_id //TODO: at event
};
const m::user::id &sender
{
at<"sender"_>(event)
};
//TODO: ircd.presence
if(my(event) && my(room) && !my(sender))
return;
const m::room::power power
{
room
};
const auto &state_key
{
json::get<"state_key"_>(event)
};
if(!power(sender, "events", type, state_key))
log::warning //TODO: throw
{
m::log, "Power violation %s in %s for %s %s,%s",
string_view{sender},
string_view{room_id},
string_view{event_id},
type,
state_key
};
}
const m::hookfn<m::vm::eval &>
_has_power_hookfn
{
_has_power,
{
{ "_site", "vm.eval" },
}
};
static void
_can_change_levels(const m::event &event,
m::vm::eval &)
{
//TODO: abstract event check against existing power levels should
//TODO: cover this?
}
const m::hookfn<m::vm::eval &>
_can_change_levels_hookfn
{
_can_change_levels,
{
{ "_site", "vm.eval" },
{ "type", "m.room.power_levels" },
}
};
static void
_changed_levels(const m::event &event,
m::vm::eval &)