0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-26 18:38:52 +02:00

modules/federation: Add various visibility conditionals.

This commit is contained in:
Jason Volk 2018-05-31 05:56:02 -07:00
parent 9028b1350a
commit 118671309d
6 changed files with 52 additions and 2 deletions

View file

@ -79,6 +79,12 @@ get__backfill(client &client,
m::head(room_id)
};
if(!visible(event_id, request.node_id))
throw m::ACCESS_DENIED
{
"You are not permitted to view the room at this event."
};
const size_t limit
{
calc_limit(request)
@ -124,7 +130,13 @@ get__backfill(client &client,
size_t count{0};
for(; it && count < limit; ++count, --it)
pdus.append(*it);
{
const m::event &event(*it);
if(!visible(event, request.node_id))
continue;
pdus.append(event);
}
return {};
}

View file

@ -75,6 +75,17 @@ get__backfill_ids(client &client,
m::head(room_id)
};
const m::room room
{
room_id, event_id
};
if(!room.visible(request.node_id))
throw m::ACCESS_DENIED
{
"You are not permitted to view the room at this event"
};
const size_t limit
{
calc_limit(request)
@ -115,7 +126,13 @@ get__backfill_ids(client &client,
size_t count{0};
for(; it && count < limit; ++count, --it)
pdus.append(it.event_id());
{
const auto &event_id(it.event_id());
if(!visible(event_id, request.node_id))
continue;
pdus.append(event_id);
}
return {};
}

View file

@ -38,6 +38,12 @@ handle_get(client &client,
url::decode(request.parv[0], event_id)
};
if(!visible(event_id, request.node_id))
throw m::ACCESS_DENIED
{
"You are not permitted to view this event"
};
const unique_buffer<mutable_buffer> buffer
{
64_KiB

View file

@ -118,6 +118,9 @@ get__missing_events(client &client,
for(; it && ret.size() < limit && goose < size_t(max_goose); ++it, ++goose)
{
const m::event &event{*it};
if(!visible(event, request.node_id))
continue;
ret.emplace_back(json::strung{event});
if(in_latest(at<"event_id"_>(event)))
break;

View file

@ -51,6 +51,12 @@ get__state(client &client,
room_id, event_id
};
if(!room.visible(request.node_id))
throw m::ACCESS_DENIED
{
"You are not permitted to view the room at this event"
};
const m::room::state state
{
room

View file

@ -44,6 +44,12 @@ get__state_ids(client &client,
room_id, event_id
};
if(!room.visible(request.node_id))
throw m::ACCESS_DENIED
{
"You are not permitted to view the room at this event"
};
const m::room::state state
{
room