This commit is contained in:
Neil Alexander 2020-08-17 17:13:50 +01:00
parent bd2e9b6211
commit bc8ef40f05
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 15 additions and 9 deletions

View file

@ -373,23 +373,21 @@ func createRoom(
// If this is a direct message then we should invite the participants. // If this is a direct message then we should invite the participants.
if len(r.Invite) > 0 { if len(r.Invite) > 0 {
// Build some stripped state for the invite. // Build some stripped state for the invite.
var strippedState []gomatrixserverlib.InviteV2StrippedState var globalStrippedState []gomatrixserverlib.InviteV2StrippedState
for _, event := range builtEvents { for _, event := range builtEvents {
switch event.Type() { switch event.Type() {
case gomatrixserverlib.MRoomName: case gomatrixserverlib.MRoomName:
fallthrough fallthrough
case gomatrixserverlib.MRoomCanonicalAlias: case gomatrixserverlib.MRoomCanonicalAlias:
fallthrough fallthrough
case "m.room.avatar": // TODO: move this to gmsl
fallthrough
case "m.room.encryption": // TODO: move this to gmsl case "m.room.encryption": // TODO: move this to gmsl
fallthrough fallthrough
case gomatrixserverlib.MRoomMember: case gomatrixserverlib.MRoomMember:
fallthrough fallthrough
case gomatrixserverlib.MRoomJoinRules: case gomatrixserverlib.MRoomJoinRules:
ev := event.Unwrap() ev := event.Event
strippedState = append( globalStrippedState = append(
strippedState, globalStrippedState,
gomatrixserverlib.NewInviteV2StrippedState(&ev), gomatrixserverlib.NewInviteV2StrippedState(&ev),
) )
} }
@ -406,12 +404,16 @@ func createRoom(
util.GetLogger(req.Context()).WithError(err).Error("buildMembershipEvent failed") util.GetLogger(req.Context()).WithError(err).Error("buildMembershipEvent failed")
continue continue
} }
inviteStrippedState := append(
globalStrippedState,
gomatrixserverlib.NewInviteV2StrippedState(&inviteEvent.Event),
)
// Send the invite event to the roomserver. // Send the invite event to the roomserver.
err = roomserverAPI.SendInvite( err = roomserverAPI.SendInvite(
req.Context(), req.Context(),
rsAPI, rsAPI,
inviteEvent.Headered(roomVersion), inviteEvent.Headered(roomVersion),
strippedState, // invite room state inviteStrippedState, // invite room state
cfg.Matrix.ServerName, // send as server cfg.Matrix.ServerName, // send as server
nil, // transaction ID nil, // transaction ID
) )

View file

@ -57,7 +57,10 @@ func (r *RoomserverInternalAPI) PerformInvite(
var isAlreadyJoined bool var isAlreadyJoined bool
roomNID, err := r.DB.RoomNID(ctx, roomID) roomNID, err := r.DB.RoomNID(ctx, roomID)
if err == nil { 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 isAlreadyJoined {
// If the user is joined to the room then that takes precedence over this // 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, Kind: api.KindNew,
Event: event, Event: event,
AuthEventIDs: event.AuthEventIDs(), AuthEventIDs: event.AuthEventIDs(),
SendAsServer: string(r.Cfg.Matrix.ServerName), SendAsServer: req.SendAsServer,
}, },
}, },
} }

View file

@ -455,3 +455,4 @@ Banned servers cannot backfill
Inbound /v1/send_leave rejects leaves from other servers Inbound /v1/send_leave rejects leaves from other servers
Guest users can accept invites to private rooms over federation Guest users can accept invites to private rooms over federation
AS user (not ghost) can join room without registering 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