diff --git a/clientapi/routing/createroom.go b/clientapi/routing/createroom.go index ae1adfac3..57fc3f33a 100644 --- a/clientapi/routing/createroom.go +++ b/clientapi/routing/createroom.go @@ -373,23 +373,21 @@ func createRoom( // If this is a direct message then we should invite the participants. if len(r.Invite) > 0 { // Build some stripped state for the invite. - var strippedState []gomatrixserverlib.InviteV2StrippedState + var globalStrippedState []gomatrixserverlib.InviteV2StrippedState for _, event := range builtEvents { switch event.Type() { case gomatrixserverlib.MRoomName: fallthrough case gomatrixserverlib.MRoomCanonicalAlias: fallthrough - case "m.room.avatar": // TODO: move this to gmsl - fallthrough case "m.room.encryption": // TODO: move this to gmsl fallthrough case gomatrixserverlib.MRoomMember: fallthrough case gomatrixserverlib.MRoomJoinRules: - ev := event.Unwrap() - strippedState = append( - strippedState, + ev := event.Event + globalStrippedState = append( + globalStrippedState, gomatrixserverlib.NewInviteV2StrippedState(&ev), ) } @@ -406,12 +404,16 @@ func createRoom( util.GetLogger(req.Context()).WithError(err).Error("buildMembershipEvent failed") continue } + inviteStrippedState := append( + globalStrippedState, + gomatrixserverlib.NewInviteV2StrippedState(&inviteEvent.Event), + ) // Send the invite event to the roomserver. err = roomserverAPI.SendInvite( req.Context(), rsAPI, inviteEvent.Headered(roomVersion), - strippedState, // invite room state + inviteStrippedState, // invite room state cfg.Matrix.ServerName, // send as server nil, // transaction ID ) diff --git a/roomserver/internal/perform_invite.go b/roomserver/internal/perform_invite.go index 3bd6f6cb7..aab3e8a8a 100644 --- a/roomserver/internal/perform_invite.go +++ b/roomserver/internal/perform_invite.go @@ -57,7 +57,10 @@ func (r *RoomserverInternalAPI) PerformInvite( var isAlreadyJoined bool roomNID, err := r.DB.RoomNID(ctx, roomID) if err == nil { - _, isAlreadyJoined, _ = r.DB.GetMembership(ctx, roomNID, *event.StateKey()) + _, isAlreadyJoined, err = r.DB.GetMembership(ctx, roomNID, *event.StateKey()) + if err != nil { + return fmt.Errorf("r.DB.GetMembership: %w", err) + } } if isAlreadyJoined { // If the user is joined to the room then that takes precedence over this @@ -146,7 +149,7 @@ func (r *RoomserverInternalAPI) PerformInvite( Kind: api.KindNew, Event: event, AuthEventIDs: event.AuthEventIDs(), - SendAsServer: string(r.Cfg.Matrix.ServerName), + SendAsServer: req.SendAsServer, }, }, } diff --git a/sytest-whitelist b/sytest-whitelist index 840d58a76..8084bbe39 100644 --- a/sytest-whitelist +++ b/sytest-whitelist @@ -455,3 +455,4 @@ Banned servers cannot backfill Inbound /v1/send_leave rejects leaves from other servers Guest users can accept invites to private rooms over federation AS user (not ghost) can join room without registering +If user leaves room, remote user changes device and rejoins we see update in /sync and /keys/changes