Fix some checks

This commit is contained in:
Tulir Asokan 2023-07-12 02:49:27 +03:00
parent 1f45d5bdec
commit e1603932aa

View file

@ -50,6 +50,7 @@ func (portal *Portal) missedForwardBackfill(user *User, lastMessageTS time.Time,
Str("action", "missed forward backfill").
Logger()
ctx := log.WithContext(context.TODO())
if !lastMessageTS.IsZero() {
if portal.lastMessageTS.IsZero() {
lastMsg, err := portal.bridge.DB.Message.GetLastInChat(ctx, portal.Key)
if err != nil {
@ -69,6 +70,7 @@ func (portal *Portal) missedForwardBackfill(user *User, lastMessageTS time.Time,
Msg("Nothing to backfill")
return
}
}
log.Info().
Time("latest_message_ts", lastMessageTS).
Str("latest_message_id", lastMessageID).
@ -115,6 +117,10 @@ func (portal *Portal) forwardBackfill(ctx context.Context, user *User, after tim
}
}
}
if len(converted) == 0 {
log.Debug().Msg("Didn't get any converted messages")
return
}
log.Debug().
Int("converted_count", len(converted)).
Msg("Converted messages for backfill")