p2p: Implement published rooms (#923)

* Create and glue ExternalPublicRoomsProvider into the public rooms component

This is how we will link p2p stuff to dendrite proper.

* Use gmsl structs rather than our own

* Implement federated public rooms

- Make thirdparty endpoint r0 so riot-web loads the public room list

* Typo

* Missing callsites
This commit is contained in:
Kegsay 2020-03-19 11:04:08 +00:00 committed by GitHub
parent dc06c69887
commit bfbf96eec9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 263 additions and 81 deletions

View file

@ -22,9 +22,9 @@ import (
"fmt"
"github.com/matrix-org/dendrite/common"
"github.com/matrix-org/gomatrixserverlib"
"github.com/lib/pq"
"github.com/matrix-org/dendrite/publicroomsapi/types"
)
var editableAttributes = []string{
@ -177,7 +177,7 @@ func (s *publicRoomsStatements) countPublicRooms(ctx context.Context) (nb int64,
func (s *publicRoomsStatements) selectPublicRooms(
ctx context.Context, offset int64, limit int16, filter string,
) ([]types.PublicRoom, error) {
) ([]gomatrixserverlib.PublicRoom, error) {
var rows *sql.Rows
var err error
@ -203,17 +203,17 @@ func (s *publicRoomsStatements) selectPublicRooms(
}
if err != nil {
return []types.PublicRoom{}, nil
return []gomatrixserverlib.PublicRoom{}, nil
}
defer common.CloseAndLogIfError(ctx, rows, "selectPublicRooms: rows.close() failed")
rooms := []types.PublicRoom{}
rooms := []gomatrixserverlib.PublicRoom{}
for rows.Next() {
var r types.PublicRoom
var r gomatrixserverlib.PublicRoom
var aliases pq.StringArray
err = rows.Scan(
&r.RoomID, &r.NumJoinedMembers, &aliases, &r.CanonicalAlias,
&r.RoomID, &r.JoinedMembersCount, &aliases, &r.CanonicalAlias,
&r.Name, &r.Topic, &r.WorldReadable, &r.GuestCanJoin, &r.AvatarURL,
)
if err != nil {

View file

@ -21,7 +21,6 @@ import (
"encoding/json"
"github.com/matrix-org/dendrite/common"
"github.com/matrix-org/dendrite/publicroomsapi/types"
"github.com/matrix-org/gomatrixserverlib"
)
@ -85,7 +84,7 @@ func (d *PublicRoomsServerDatabase) CountPublicRooms(ctx context.Context) (int64
// Returns an error if the retrieval failed.
func (d *PublicRoomsServerDatabase) GetPublicRooms(
ctx context.Context, offset int64, limit int16, filter string,
) ([]types.PublicRoom, error) {
) ([]gomatrixserverlib.PublicRoom, error) {
return d.statements.selectPublicRooms(ctx, offset, limit, filter)
}