mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-10 23:53:09 -06:00
Actually filter on room_nid; Update comment
This commit is contained in:
parent
2006683c6f
commit
50fd515331
|
|
@ -204,7 +204,8 @@ type UserRoomKeys interface {
|
|||
InsertUserRoomPublicKey(ctx context.Context, userID spec.UserID, roomID spec.RoomID, key ed25519.PublicKey) (result ed25519.PublicKey, err error)
|
||||
// SelectUserRoomPrivateKey selects the private key for the given user and room combination
|
||||
SelectUserRoomPrivateKey(ctx context.Context, userID spec.UserID, roomID spec.RoomID) (key ed25519.PrivateKey, err error)
|
||||
// SelectUserIDsForPublicKeys selects all userIDs for the requested senderKeys. Returns a map from roomID -> map from publicKey to userID
|
||||
// SelectUserIDsForPublicKeys selects all userIDs for the requested senderKeys. Returns a map from roomID -> map from publicKey to userID.
|
||||
// If a senderKey can't be found, it is omitted in the result.
|
||||
SelectUserIDsForPublicKeys(ctx context.Context, publicKeys map[spec.RoomID][]ed25519.PublicKey) (map[spec.RoomID]map[string]string, error)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ const insertUserRoomPublicKeySQL = `
|
|||
|
||||
const selectUserRoomKeySQL = `SELECT pseudo_id_key FROM roomserver_user_room_keys WHERE user_nid = $1 AND room_nid = $2`
|
||||
|
||||
const selectUserNIDsSQL = `SELECT user_nid, room_nid, pseudo_id_pub_key FROM roomserver_user_room_keys WHERE pseudo_id_pub_key = ANY($1)`
|
||||
const selectUserNIDsSQL = `SELECT user_nid, room_nid, pseudo_id_pub_key FROM roomserver_user_room_keys WHERE room_nid = ANY($1) AND pseudo_id_pub_key = ANY($2)`
|
||||
|
||||
type userRoomKeysStatements struct {
|
||||
insertUserRoomPrivateKeyStmt *sql.Stmt
|
||||
|
|
@ -113,7 +113,7 @@ func (s *userRoomKeysStatements) BulkSelectUserNIDs(ctx context.Context, txn *sq
|
|||
senders = append(senders, key)
|
||||
}
|
||||
}
|
||||
rows, err := stmt.QueryContext(ctx, pq.Array(senders))
|
||||
rows, err := stmt.QueryContext(ctx, pq.Array(roomNIDs), pq.Array(senders))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1733,14 +1733,14 @@ func (d *Database) SelectUserIDsForPublicKeys(ctx context.Context, publicKeys ma
|
|||
nids = append(nids, nid.EventStateKeyNID)
|
||||
}
|
||||
// get the userIDs
|
||||
nidMAP, seErr := d.EventStateKeys(ctx, nids)
|
||||
nidMap, seErr := d.EventStateKeys(ctx, nids)
|
||||
if seErr != nil {
|
||||
return seErr
|
||||
}
|
||||
|
||||
// build the result map (roomID -> map publicKey -> userID)
|
||||
for publicKey, userRoomKeyPair := range userRoomKeyPairMap {
|
||||
userID := nidMAP[userRoomKeyPair.EventStateKeyNID]
|
||||
userID := nidMap[userRoomKeyPair.EventStateKeyNID]
|
||||
roomID := rooms[userRoomKeyPair.RoomNID]
|
||||
resMap, exists := result[roomID]
|
||||
if !exists {
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ type UserRoomKeys interface {
|
|||
// SelectUserRoomPrivateKey selects the private key for the given user and room combination
|
||||
SelectUserRoomPrivateKey(ctx context.Context, txn *sql.Tx, userNID types.EventStateKeyNID, roomNID types.RoomNID) (ed25519.PrivateKey, error)
|
||||
// BulkSelectUserNIDs selects all userIDs for the requested senderKeys. Returns a map from publicKey -> types.UserRoomKeyPair.
|
||||
// If a senderKey can't be found, it is omitted in the result.
|
||||
BulkSelectUserNIDs(ctx context.Context, txn *sql.Tx, senderKeys map[types.RoomNID][]ed25519.PublicKey) (map[string]types.UserRoomKeyPair, error)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue