Skip to content

Commit

Permalink
ircd::m::rooms: Implement matrix-org/matrix-spec-proposals#3827
Browse files Browse the repository at this point in the history
  • Loading branch information
jevolk committed Apr 22, 2023
1 parent 1a032b2 commit 238cc10
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/ircd/m/rooms.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ struct ircd::m::rooms::opts
/// Room alias prefix search
string_view room_alias;

/// Room type search
string_view room_type;

/// user::rooms convenience
id::user user_id;

Expand Down
4 changes: 4 additions & 0 deletions matrix/rooms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ ircd::m::rooms::for_each(const opts &opts,
if(!join_rule(room, opts.join_rule))
return;

if(opts.room_type)
if(!m::type(room_id, opts.room_type))
return;

if(opts.server && opts.request_node_id && my_host(opts.server))
if(!room::aliases(room_id).has_server(opts.server))
return;
Expand Down
1 change: 1 addition & 0 deletions modules/client/publicrooms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ get__publicrooms(client &client,
opts.lower_bound = true;
opts.room_id = since;
opts.request_user_id = request.user_id;
opts.room_type = json::string{filter["room_type"]};
if(m::valid(m::id::USER, search_term))
opts.user_id = search_term;

Expand Down
9 changes: 9 additions & 0 deletions modules/client/versions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,13 @@ ircd::m::client_versions::append_unstable_features(client &client,
bool(e2ee_forced_trusted_private)
}
};

// Supports filtering of /publicRooms by room type as per MSC3827
json::stack::member
{
out, "org.matrix.msc3827.stable", json::value
{
true
}
};
}
1 change: 1 addition & 0 deletions modules/federation/publicrooms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ handle_get(client &client,
opts.room_id = since;
opts.search_term = search_term;
opts.request_node_id = request.node_id;
opts.room_type = json::string(filter["room_type"]);

size_t count{0};
m::room::id::buf prev_batch_buf;
Expand Down

0 comments on commit 238cc10

Please sign in to comment.