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 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
)

View file

@ -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,
},
},
}

View file

@ -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