mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-09 23:23:10 -06:00
Fix event federation for pseudoIDs
This commit is contained in:
parent
297479ea49
commit
c62628d0f6
|
|
@ -123,6 +123,7 @@ func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederatio
|
||||||
ServerName: r.ServerName,
|
ServerName: r.ServerName,
|
||||||
SigningIdentity: r.SigningIdentityFor,
|
SigningIdentity: r.SigningIdentityFor,
|
||||||
FSAPI: fsAPI,
|
FSAPI: fsAPI,
|
||||||
|
RSAPI: r,
|
||||||
KeyRing: keyRing,
|
KeyRing: keyRing,
|
||||||
ACLs: r.ServerACLs,
|
ACLs: r.ServerACLs,
|
||||||
Queryer: r.Queryer,
|
Queryer: r.Queryer,
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ type Inputer struct {
|
||||||
ServerName spec.ServerName
|
ServerName spec.ServerName
|
||||||
SigningIdentity func(ctx context.Context, roomID spec.RoomID, senderID spec.UserID) (fclient.SigningIdentity, error)
|
SigningIdentity func(ctx context.Context, roomID spec.RoomID, senderID spec.UserID) (fclient.SigningIdentity, error)
|
||||||
FSAPI fedapi.RoomserverFederationAPI
|
FSAPI fedapi.RoomserverFederationAPI
|
||||||
|
RSAPI api.RoomserverInternalAPI
|
||||||
KeyRing gomatrixserverlib.JSONVerifier
|
KeyRing gomatrixserverlib.JSONVerifier
|
||||||
ACLs *acls.ServerACLs
|
ACLs *acls.ServerACLs
|
||||||
InputRoomEventTopic string
|
InputRoomEventTopic string
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,24 @@ func (r *Inputer) processRoomEvent(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Revist this to ensure we don't replace a current state mxid_mapping with an older one.
|
||||||
|
if event.Type() == spec.MRoomMember {
|
||||||
|
mapping := gomatrixserverlib.MemberContent{}
|
||||||
|
if err := json.Unmarshal(event.Content(), &mapping); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if mapping.MXIDMapping != nil {
|
||||||
|
storeUserID, userErr := spec.NewUserID(mapping.MXIDMapping.UserID, true)
|
||||||
|
if userErr != nil {
|
||||||
|
return userErr
|
||||||
|
}
|
||||||
|
err = r.RSAPI.StoreUserRoomPublicKey(ctx, mapping.MXIDMapping.UserRoomKey, *storeUserID, *validRoomID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed storing user room public key: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch input.Kind {
|
switch input.Kind {
|
||||||
case api.KindNew:
|
case api.KindNew:
|
||||||
if err = r.updateLatestEvents(
|
if err = r.updateLatestEvents(
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,6 @@ func (r *Joiner) performJoinRoomByID(
|
||||||
// If we should do a forced federated join then do that.
|
// If we should do a forced federated join then do that.
|
||||||
var joinedVia spec.ServerName
|
var joinedVia spec.ServerName
|
||||||
if forceFederatedJoin {
|
if forceFederatedJoin {
|
||||||
// TODO : pseudoIDs - pass through userID here since we don't know what the senderID should be yet
|
|
||||||
joinedVia, err = r.performFederatedJoinRoomByID(ctx, req)
|
joinedVia, err = r.performFederatedJoinRoomByID(ctx, req)
|
||||||
return req.RoomIDOrAlias, joinedVia, err
|
return req.RoomIDOrAlias, joinedVia, err
|
||||||
}
|
}
|
||||||
|
|
@ -286,10 +285,7 @@ func (r *Joiner) performJoinRoomByID(
|
||||||
// but everyone has since left. I suspect it does the wrong thing.
|
// but everyone has since left. I suspect it does the wrong thing.
|
||||||
|
|
||||||
var buildRes rsAPI.QueryLatestEventsAndStateResponse
|
var buildRes rsAPI.QueryLatestEventsAndStateResponse
|
||||||
identity, err := r.RSAPI.SigningIdentityFor(ctx, *roomID, *userID)
|
identity := r.Cfg.Matrix.SigningIdentity
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("error joining local room: %q", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// at this point we know we have an existing room
|
// at this point we know we have an existing room
|
||||||
if inRoomRes.RoomVersion == gomatrixserverlib.RoomVersionPseudoIDs {
|
if inRoomRes.RoomVersion == gomatrixserverlib.RoomVersionPseudoIDs {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue