SendEventWithState accepts Kind argument

This commit is contained in:
Neil Alexander 2020-08-28 16:42:44 +01:00
parent 3a5c0922e7
commit 9c6d1eb54e
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 10 additions and 7 deletions

View file

@ -457,7 +457,7 @@ func (t *txnReq) processEventWithMissingState(e gomatrixserverlib.Event, roomVer
// pass the event along with the state to the roomserver using a background context so we don't
// needlessly expire
return api.SendEventWithState(context.Background(), t.rsAPI, resolvedState, e.Headered(roomVersion), t.haveEventIDs())
return api.SendEventWithState(context.Background(), t.rsAPI, resolvedState, e.Headered(roomVersion), t.haveEventIDs(), api.KindOutlier)
}
// lookupStateAfterEvent returns the room state after `eventID`, which is the state before eventID with the state of `eventID` (if it's a state event)

View file

@ -198,7 +198,9 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
if err = roomserverAPI.SendEventWithState(
ctx, r.rsAPI,
&respState,
event.Headered(respMakeJoin.RoomVersion), nil,
event.Headered(respMakeJoin.RoomVersion),
nil,
roomserverAPI.KindNew,
); err != nil {
return fmt.Errorf("r.producer.SendEventWithState: %w", err)
}

View file

@ -40,12 +40,13 @@ func SendEvents(
return SendInputRoomEvents(ctx, rsAPI, ires)
}
// SendEventWithState writes an event with KindNew to the roomserver
// with the state at the event as KindOutlier before it. Will not send any event that is
// marked as `true` in haveEventIDs
// SendEventWithState writes an event with KindNew to the roomserver with
// the state at the event before it. The state events will be sent to the
// roomserver as the given "stateKind", e.g. new, outlier. Will not send
// any event that is marked as `true` in haveEventIDs
func SendEventWithState(
ctx context.Context, rsAPI RoomserverInternalAPI, state *gomatrixserverlib.RespState,
event gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
event gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool, stateKind Kind,
) error {
outliers, err := state.Events()
if err != nil {
@ -58,7 +59,7 @@ func SendEventWithState(
continue
}
ires = append(ires, InputRoomEvent{
Kind: KindOutlier,
Kind: stateKind,
Event: outlier.Headered(event.RoomVersion),
AuthEventIDs: outlier.AuthEventIDs(),
})