Move checking if the event has been sent as well

This commit is contained in:
Till Faelligen 2023-11-24 10:05:30 +01:00
parent 94960c507a
commit 2f99680c38
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -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(