mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-13 01:43:09 -06:00
Documentation and other misc touchups
This commit is contained in:
parent
0ad58b5a45
commit
e1a5d973d2
|
|
@ -31,7 +31,7 @@ type response struct {
|
|||
}
|
||||
|
||||
type joinedResponse struct {
|
||||
JoinedRooms []string `json:"joined_rooms,flow"`
|
||||
JoinedRooms []string `json:"joined_rooms"`
|
||||
}
|
||||
|
||||
// GetMemberships implements GET /rooms/{roomId}/members
|
||||
|
|
|
|||
|
|
@ -412,6 +412,7 @@ func (h *httpRoomserverQueryAPI) QueryMembershipsForRoom(
|
|||
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
// QueryRoomsForUser implements RoomserverQueryAPI
|
||||
func (h *httpRoomserverQueryAPI) QueryRoomsForUser(
|
||||
ctx context.Context,
|
||||
request *QueryRoomsForUserRequest,
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ type RoomserverQueryAPIDatabase interface {
|
|||
ctx context.Context, roomNID types.RoomNID, joinOnly bool,
|
||||
) ([]types.EventNID, error)
|
||||
// Lookup the rooms for which a user has a particular membership state.
|
||||
// Returns an error if there was a problem talkign to the database.
|
||||
// Returns an error if there was a problem talking to the database.
|
||||
GetRoomsForUserMembership(
|
||||
ctx context.Context, userNID types.EventStateKeyNID, membership string,
|
||||
) ([]types.RoomNID, error)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package storage
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
// Import the postgres database driver.
|
||||
_ "github.com/lib/pq"
|
||||
|
|
@ -412,6 +413,7 @@ func (d *Database) RoomNID(ctx context.Context, roomID string) (types.RoomNID, e
|
|||
return roomNID, err
|
||||
}
|
||||
|
||||
// GetRoomIDs implements query.RoomserverQueryAPIDatabase
|
||||
func (d *Database) GetRoomIDs(ctx context.Context, roomNIDs []types.RoomNID) ([]string, error) {
|
||||
roomIDs := make([]string, 0)
|
||||
|
||||
|
|
@ -446,16 +448,21 @@ func (d *Database) LatestEventIDs(
|
|||
return references, currentStateSnapshotNID, depth, nil
|
||||
}
|
||||
|
||||
// GetRoomsForUserMembership implements query.RoomserverQueryAPIDatabase
|
||||
func (d *Database) GetRoomsForUserMembership(
|
||||
ctx context.Context,
|
||||
userNID types.EventStateKeyNID,
|
||||
membership string,
|
||||
) (roomNIDs []types.RoomNID, err error) {
|
||||
membershipNID := membershipStateLeaveOrBan
|
||||
var membershipNID membershipState
|
||||
if membership == "join" {
|
||||
membershipNID = membershipStateJoin
|
||||
} else if membership == "invite" {
|
||||
membershipNID = membershipStateInvite
|
||||
} else if membership == "ban" || membership == "leave" {
|
||||
membershipNID = membershipStateLeaveOrBan
|
||||
} else {
|
||||
return nil, errors.New("invalid membership")
|
||||
}
|
||||
return d.statements.selectRoomsForUserMembership(ctx, userNID, membershipNID)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue