Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Move creation of pseudo ID keys to the roomserver
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK committed Jun 28, 2023
1 parent 88b0f6a commit 6697f43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
19 changes: 0 additions & 19 deletions clientapi/routing/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,25 +454,6 @@ func buildMembershipEvent(
return nil, err
}

// If we're inviting a local user, we can generate the needed key here.
if targetSenderID == "" && cfg.Matrix.IsLocalServerName(targetID.Domain()) { // todo: remove
var roomVersion gomatrixserverlib.RoomVersion
roomVersion, err = rsAPI.QueryRoomVersionForRoom(ctx, roomID)
if err != nil {
return nil, err
}
switch roomVersion {
case gomatrixserverlib.RoomVersionPseudoIDs:
var key ed25519.PrivateKey
key, err = rsAPI.GetOrCreateUserRoomPrivateKey(ctx, *targetID, *validRoomID)
if err != nil {
return nil, err
}
targetSenderID = spec.SenderIDFromPseudoIDKey(key)
}

}

identity, err := rsAPI.SigningIdentityFor(ctx, *validRoomID, *userID)
if err != nil {
return nil, err
Expand Down
17 changes: 17 additions & 0 deletions roomserver/internal/perform/perform_invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ func (r *Inviter) PerformInvite(
}
isTargetLocal := r.Cfg.Matrix.IsLocalServerName(invitedUser.Domain())

// If we're inviting a local user, we can generate the needed pseudoID key here. (if needed)
if isTargetLocal {
var roomVersion gomatrixserverlib.RoomVersion
roomVersion, err = r.DB.GetRoomVersion(ctx, event.RoomID())
if err != nil {
return err
}

switch roomVersion {
case gomatrixserverlib.RoomVersionPseudoIDs:
_, err = r.RSAPI.GetOrCreateUserRoomPrivateKey(ctx, *invitedUser, *validRoomID)
if err != nil {
return err
}
}
}

invitedSenderID, err := r.RSAPI.QuerySenderIDForUser(ctx, *validRoomID, *invitedUser)
if err != nil {
return fmt.Errorf("failed looking up senderID for invited user")
Expand Down

0 comments on commit 6697f43

Please sign in to comment.