From 2f99680c38bb0d0d43a32d36b7072c5267f5886e Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:05:30 +0100 Subject: [PATCH] Move checking if the event has been sent as well --- .../internal/input/input_latest_events.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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(