0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-01 21:28:53 +02:00

modules/federation: Add access conditions for make_join/make_leave.

This commit is contained in:
Jason Volk 2019-04-17 05:24:28 -07:00
parent b2bb0b70d2
commit 655d56a849
2 changed files with 41 additions and 0 deletions

View file

@ -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);

View file

@ -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);