Federation sender to ignore invites that are destined locally

This commit is contained in:
Neil Alexander 2020-05-06 14:52:00 +01:00
parent 7ac699bc77
commit 7ff2bbf13e

View file

@ -188,6 +188,25 @@ func (s *OutputRoomEventConsumer) processInvite(oie api.OutputNewInviteEvent) er
return nil return nil
} }
// Ignore invites that don't have state keys - they are invalid.
if oie.Event.StateKey() == nil {
return fmt.Errorf("event %q doesn't have state key", oie.Event.EventID())
}
// Don't try to handle events that are actually destined for us.
stateKey := *oie.Event.StateKey()
_, destination, err := gomatrixserverlib.SplitID('@', stateKey)
if err != nil {
log.WithFields(log.Fields{
"event_id": oie.Event.EventID(),
"state_key": stateKey,
}).Info("failed to split destination from state key")
return nil
}
if s.cfg.Matrix.ServerName == destination {
return nil
}
// Try to extract the room invite state. The roomserver will have stashed // Try to extract the room invite state. The roomserver will have stashed
// this for us in invite_room_state if it didn't already exist. // this for us in invite_room_state if it didn't already exist.
strippedState := []gomatrixserverlib.InviteV2StrippedState{} strippedState := []gomatrixserverlib.InviteV2StrippedState{}