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:
parent
9028b1350a
commit
118671309d
6 changed files with 52 additions and 2 deletions
|
@ -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 {};
|
||||
}
|
||||
|
|
|
@ -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 {};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue