Make PerformJoin send input membership event

This commit is contained in:
Neil Alexander 2020-08-17 13:38:58 +01:00
parent e7d450adb8
commit 8fa3002f88
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 15 additions and 25 deletions

View file

@ -118,23 +118,6 @@ func SendInvite(
return response.Error
}
// Now send the invite event into the roomserver. If the room is known
// locally then this will succeed, notifying existing users in the room
// about the new invite. If the room isn't known locally then this will
// fail - and that's also OK.
inputReq := &InputRoomEventsRequest{
InputRoomEvents: []InputRoomEvent{
{
Kind: KindNew,
Event: inviteEvent,
AuthEventIDs: inviteEvent.AuthEventIDs(),
SendAsServer: string(sendAsServer),
},
},
}
inputRes := &InputRoomEventsResponse{}
_ = rsAPI.InputRoomEvents(ctx, inputReq, inputRes)
return nil
}

View file

@ -143,15 +143,22 @@ func (r *RoomserverInternalAPI) PerformInvite(
}
}
unwrapped := event.Unwrap()
outputUpdates, err := updateToInviteMembership(updater, &unwrapped, nil, req.Event.RoomVersion)
if err != nil {
return fmt.Errorf("updateToInviteMembership: %w", err)
}
if err = r.WriteOutputEvents(roomID, outputUpdates); err != nil {
return fmt.Errorf("r.WriteOutputEvents: %w", err)
// Send the invite event to the roomserver input stream. This will
// notify existing users in the room about the invite, update the
// membership table and ensure that the event is ready and available
// to use as an auth event when accepting the invite.
inputReq := &api.InputRoomEventsRequest{
InputRoomEvents: []api.InputRoomEvent{
{
Kind: api.KindNew,
Event: event,
AuthEventIDs: event.AuthEventIDs(),
SendAsServer: string(r.Cfg.Matrix.ServerName),
},
},
}
inputRes := &api.InputRoomEventsResponse{}
_ = r.InputRoomEvents(ctx, inputReq, inputRes)
succeeded = true
return nil