mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
support SendEventWithState with optional event
This commit is contained in:
parent
4ef6a3c759
commit
65e59a1af9
|
|
@ -42,10 +42,11 @@ func SendEvents(
|
||||||
|
|
||||||
// SendEventWithState writes an event with KindNew to the roomserver
|
// 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
|
// 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(
|
func SendEventWithState(
|
||||||
ctx context.Context, rsAPI RoomserverInternalAPI, state *gomatrixserverlib.RespState,
|
ctx context.Context, rsAPI RoomserverInternalAPI, state *gomatrixserverlib.RespState,
|
||||||
event gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
|
event *gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
|
||||||
) error {
|
) error {
|
||||||
outliers, err := state.Events()
|
outliers, err := state.Events()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -69,13 +70,15 @@ func SendEventWithState(
|
||||||
stateEventIDs[i] = state.StateEvents[i].EventID()
|
stateEventIDs[i] = state.StateEvents[i].EventID()
|
||||||
}
|
}
|
||||||
|
|
||||||
ires = append(ires, InputRoomEvent{
|
if event != nil {
|
||||||
Kind: KindNew,
|
ires = append(ires, InputRoomEvent{
|
||||||
Event: event,
|
Kind: KindNew,
|
||||||
AuthEventIDs: event.AuthEventIDs(),
|
Event: *event,
|
||||||
HasState: true,
|
AuthEventIDs: event.AuthEventIDs(),
|
||||||
StateEventIDs: stateEventIDs,
|
HasState: true,
|
||||||
})
|
StateEventIDs: stateEventIDs,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return SendInputRoomEvents(ctx, rsAPI, ires)
|
return SendInputRoomEvents(ctx, rsAPI, ires)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue