aboutsummaryrefslogtreecommitdiff
path: root/federationapi/routing/publicrooms.go
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-10-27 14:40:35 +0200
committerGitHub <noreply@github.com>2022-10-27 14:40:35 +0200
commit444b4bbdb8ce6f26651c4516cb23828a65bdd065 (patch)
tree199b5d262c965acf1d885bafaa59549b3eafe0c2 /federationapi/routing/publicrooms.go
parenta169a9121aa6b2ff3e3fba6ec9777227e349300f (diff)
Add AS specific public room list endpoints (#2836)
Adds `PUT /_matrix/client/v3/directory/list/appservice/{networkId}/{roomId}` and `DELTE /_matrix/client/v3/directory/list/appservice/{networkId}/{roomId}` support, as well as the ability to filter `/publicRooms` on networkID and including all networks.
Diffstat (limited to 'federationapi/routing/publicrooms.go')
-rw-r--r--federationapi/routing/publicrooms.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/federationapi/routing/publicrooms.go b/federationapi/routing/publicrooms.go
index 1a54f5a7..34025932 100644
--- a/federationapi/routing/publicrooms.go
+++ b/federationapi/routing/publicrooms.go
@@ -2,24 +2,29 @@ package routing
import (
"context"
+ "fmt"
"net/http"
"strconv"
+ "github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/util"
+
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
- "github.com/matrix-org/gomatrixserverlib"
- "github.com/matrix-org/util"
)
type PublicRoomReq struct {
- Since string `json:"since,omitempty"`
- Limit int16 `json:"limit,omitempty"`
- Filter filter `json:"filter,omitempty"`
+ Since string `json:"since,omitempty"`
+ Limit int16 `json:"limit,omitempty"`
+ Filter filter `json:"filter,omitempty"`
+ IncludeAllNetworks bool `json:"include_all_networks,omitempty"`
+ NetworkID string `json:"third_party_instance_id,omitempty"`
}
type filter struct {
- SearchTerms string `json:"generic_search_term,omitempty"`
+ SearchTerms string `json:"generic_search_term,omitempty"`
+ RoomTypes []string `json:"room_types,omitempty"`
}
// GetPostPublicRooms implements GET and POST /publicRooms
@@ -57,8 +62,14 @@ func publicRooms(
return nil, err
}
+ if request.IncludeAllNetworks && request.NetworkID != "" {
+ return nil, fmt.Errorf("include_all_networks and third_party_instance_id can not be used together")
+ }
+
var queryRes roomserverAPI.QueryPublishedRoomsResponse
- err = rsAPI.QueryPublishedRooms(ctx, &roomserverAPI.QueryPublishedRoomsRequest{}, &queryRes)
+ err = rsAPI.QueryPublishedRooms(ctx, &roomserverAPI.QueryPublishedRoomsRequest{
+ NetworkID: request.NetworkID,
+ }, &queryRes)
if err != nil {
util.GetLogger(ctx).WithError(err).Error("QueryPublishedRooms failed")
return nil, err