mirror of
https://github.com/matrix-construct/construct
synced 2025-03-17 06:50:23 +01:00
modules/federation: Add access conditions for make_join/make_leave.
This commit is contained in:
parent
b2bb0b70d2
commit
655d56a849
2 changed files with 41 additions and 0 deletions
|
@ -61,6 +61,23 @@ get__make_join(client &client,
|
|||
url::decode(user_id, request.parv[1])
|
||||
};
|
||||
|
||||
if(user_id.host() != request.node_id.host())
|
||||
throw m::ACCESS_DENIED
|
||||
{
|
||||
"You are not permitted to spoof users on other hosts."
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
if(!room.visible(user_id))
|
||||
throw m::ACCESS_DENIED
|
||||
{
|
||||
"You are not permitted to view the room at this event."
|
||||
};
|
||||
|
||||
int64_t depth;
|
||||
m::id::event::buf prev_event_id;
|
||||
std::tie(prev_event_id, depth, std::ignore) = m::top(room_id);
|
||||
|
|
|
@ -61,6 +61,30 @@ get__make_leave(client &client,
|
|||
url::decode(user_id, request.parv[1])
|
||||
};
|
||||
|
||||
if(user_id.host() != request.node_id.host())
|
||||
throw m::ACCESS_DENIED
|
||||
{
|
||||
"You are not permitted to spoof users on other hosts."
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
char membuf[32];
|
||||
const string_view membership
|
||||
{
|
||||
room.membership(membuf, user_id)
|
||||
};
|
||||
|
||||
if(membership != "join" && membership != "invite")
|
||||
throw m::ACCESS_DENIED
|
||||
{
|
||||
"You are not permitted to leave the room with membership '%s'",
|
||||
membership
|
||||
};
|
||||
|
||||
int64_t depth;
|
||||
m::id::event::buf prev_event_id;
|
||||
std::tie(prev_event_id, depth, std::ignore) = m::top(room_id);
|
||||
|
|
Loading…
Add table
Reference in a new issue