support SendEventWithState with optional event

This commit is contained in:
Matthew Hodgson 2020-09-11 22:31:32 +01:00
parent 4ef6a3c759
commit 65e59a1af9

View file

@ -42,10 +42,11 @@ func SendEvents(
// 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
// marked as `true` in haveEventIDs. The event itself is optional in case
// hou just want to write outliers to the roomserver.
func SendEventWithState(
ctx context.Context, rsAPI RoomserverInternalAPI, state *gomatrixserverlib.RespState,
event gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
event *gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
) error {
outliers, err := state.Events()
if err != nil {
@ -69,13 +70,15 @@ func SendEventWithState(
stateEventIDs[i] = state.StateEvents[i].EventID()
}
if event != nil {
ires = append(ires, InputRoomEvent{
Kind: KindNew,
Event: event,
Event: *event,
AuthEventIDs: event.AuthEventIDs(),
HasState: true,
StateEventIDs: stateEventIDs,
})
}
return SendInputRoomEvents(ctx, rsAPI, ires)
}