backfill: fix NPE if no messages found

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2025-03-13 11:58:18 -06:00
parent 854f66cb04
commit 09b1e69c0f
+3 -1
View File
@@ -254,7 +254,9 @@ func (t *TelegramClient) FetchMessages(ctx context.Context, fetchParams bridgev2
// If the first message is the last read message, mark the chat as read
// during backfill.
markRead := fetchParams.Forward && portal.Metadata.(*PortalMetadata).ReadUpTo == messages[0].GetID()
markRead := fetchParams.Forward &&
len(messages) > 0 &&
portal.Metadata.(*PortalMetadata).ReadUpTo == messages[0].GetID()
var cursor networkid.PaginationCursor
if len(messages) > 0 {