diff --git a/roomserver/internal/input/input_latest_events.go b/roomserver/internal/input/input_latest_events.go index aa26c74d3..f6b9d0513 100644 --- a/roomserver/internal/input/input_latest_events.go +++ b/roomserver/internal/input/input_latest_events.go @@ -69,6 +69,16 @@ func (r *Inputer) updateLatestEvents( defer sqlutil.EndTransactionWithCheck(updater, &succeeded, &err) + // If the event has already been written to the output log then we + // don't need to do anything, as we've handled it already. + hasBeenSent, err := updater.HasEventBeenSent(stateAtEvent.EventNID) + if err != nil { + return fmt.Errorf("u.updater.HasEventBeenSent: %w", err) + } + if hasBeenSent { + return nil + } + u := latestEventsUpdater{ api: r, updater: updater, @@ -154,14 +164,6 @@ func (u *latestEventsUpdater) doUpdateLatestEvents(ctx context.Context, roomInfo u.oldLatest = u.updater.LatestEvents() } - // If the event has already been written to the output log then we - // don't need to do anything, as we've handled it already. - if hasBeenSent, err := u.updater.HasEventBeenSent(u.stateAtEvent.EventNID); err != nil { - return nil, fmt.Errorf("u.updater.HasEventBeenSent: %w", err) - } else if hasBeenSent { - return nil, nil - } - // Work out what the latest events are. This will include the new // event if it is not already referenced. extremitiesChanged, err := u.calculateLatest(