Fix GET /directory/list/room/{roomID}
(#2262)
* Let's try to work out why this endpoint lies * Try that again * Fix `QueryPublishedRooms` * Remove logging * Remove unnecessary change * Remove unnecessary change
This commit is contained in:
parent
030b995636
commit
089d16812c
|
@ -610,6 +610,14 @@ func (r *Queryer) QueryPublishedRooms(
|
||||||
req *api.QueryPublishedRoomsRequest,
|
req *api.QueryPublishedRoomsRequest,
|
||||||
res *api.QueryPublishedRoomsResponse,
|
res *api.QueryPublishedRoomsResponse,
|
||||||
) error {
|
) error {
|
||||||
|
if req.RoomID != "" {
|
||||||
|
visible, err := r.DB.GetPublishedRoom(ctx, req.RoomID)
|
||||||
|
if err == nil && visible {
|
||||||
|
res.RoomIDs = []string{req.RoomID}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
rooms, err := r.DB.GetPublishedRooms(ctx)
|
rooms, err := r.DB.GetPublishedRooms(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -139,6 +139,8 @@ type Database interface {
|
||||||
PublishRoom(ctx context.Context, roomID string, publish bool) error
|
PublishRoom(ctx context.Context, roomID string, publish bool) error
|
||||||
// Returns a list of room IDs for rooms which are published.
|
// Returns a list of room IDs for rooms which are published.
|
||||||
GetPublishedRooms(ctx context.Context) ([]string, error)
|
GetPublishedRooms(ctx context.Context) ([]string, error)
|
||||||
|
// Returns whether a given room is published or not.
|
||||||
|
GetPublishedRoom(ctx context.Context, roomID string) (bool, error)
|
||||||
|
|
||||||
// TODO: factor out - from currentstateserver
|
// TODO: factor out - from currentstateserver
|
||||||
|
|
||||||
|
|
|
@ -669,6 +669,10 @@ func (d *Database) PublishRoom(ctx context.Context, roomID string, publish bool)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Database) GetPublishedRoom(ctx context.Context, roomID string) (bool, error) {
|
||||||
|
return d.PublishedTable.SelectPublishedFromRoomID(ctx, nil, roomID)
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Database) GetPublishedRooms(ctx context.Context) ([]string, error) {
|
func (d *Database) GetPublishedRooms(ctx context.Context) ([]string, error) {
|
||||||
return d.PublishedTable.SelectAllPublishedRooms(ctx, nil, true)
|
return d.PublishedTable.SelectAllPublishedRooms(ctx, nil, true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue