mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
Merge SenderID & Per Room User Key work (#3109)
This commit is contained in:
parent
7a2e325d10
commit
e4665979bf
75 changed files with 801 additions and 379 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
|
||||
"github.com/matrix-org/dendrite/roomserver/api"
|
||||
"github.com/matrix-org/dendrite/roomserver/state"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
|
@ -36,6 +37,7 @@ func CheckForSoftFail(
|
|||
roomInfo *types.RoomInfo,
|
||||
event *types.HeaderedEvent,
|
||||
stateEventIDs []string,
|
||||
querier api.QuerySenderIDAPI,
|
||||
) (bool, error) {
|
||||
rewritesState := len(stateEventIDs) > 1
|
||||
|
||||
|
@ -49,7 +51,7 @@ func CheckForSoftFail(
|
|||
} else {
|
||||
// Then get the state entries for the current state snapshot.
|
||||
// We'll use this to check if the event is allowed right now.
|
||||
roomState := state.NewStateResolution(db, roomInfo)
|
||||
roomState := state.NewStateResolution(db, roomInfo, querier)
|
||||
authStateEntries, err = roomState.LoadStateAtSnapshot(ctx, roomInfo.StateSnapshotNID())
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("roomState.LoadStateAtSnapshot: %w", err)
|
||||
|
@ -76,8 +78,8 @@ func CheckForSoftFail(
|
|||
}
|
||||
|
||||
// Check if the event is allowed.
|
||||
if err = gomatrixserverlib.Allowed(event.PDU, &authEvents, func(roomID string, senderID spec.SenderID) (*spec.UserID, error) {
|
||||
return db.GetUserIDForSender(ctx, roomID, senderID)
|
||||
if err = gomatrixserverlib.Allowed(event.PDU, &authEvents, func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
|
||||
return querier.QueryUserIDForSender(ctx, roomID, senderID)
|
||||
}); err != nil {
|
||||
// return true, nil
|
||||
return true, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue