directdownload,tomatrix: add missing nil checks

This commit is contained in:
Tulir Asokan
2025-12-03 16:03:29 +02:00
parent 1ecb9e8b64
commit 35c161185c
2 changed files with 10 additions and 6 deletions
+4 -4
View File
@@ -191,10 +191,10 @@ func (tc *TelegramConnector) Download(ctx context.Context, mediaID networkid.Med
chatFull, ok := fullChat.FullChat.(*tg.ChatFull)
if !ok {
return nil, fmt.Errorf("full chat is %T not *tg.ChatFull", fullChat.FullChat)
}
// FIXME: this is basically a not found error
if photoID := chatFull.ChatPhoto.GetID(); photoID != info.ID {
} else if chatFull.ChatPhoto == nil {
// FIXME: these 2 are basically not found errors
return nil, fmt.Errorf("photo not found on chat")
} else if photoID := chatFull.ChatPhoto.GetID(); photoID != info.ID {
return nil, fmt.Errorf("photo id mismatch: %d != %d", photoID, info.ID)
}
+6 -2
View File
@@ -400,8 +400,12 @@ func (c *TelegramClient) convertMediaRequiringUpload(ctx context.Context, portal
} else {
content.Body = "image"
}
telegramMediaID = msgMedia.Photo.GetID()
mediaTransferer = transferer.WithPhoto(msgMedia.Photo)
photo, ok := msgMedia.Photo.(*tg.Photo)
if !ok {
return nil, nil, fmt.Errorf("unrecognized photo type %T", msgMedia.Photo)
}
telegramMediaID = photo.GetID()
mediaTransferer = transferer.WithPhoto(photo)
case *tg.MessageMediaDocument:
document, ok := msgMedia.Document.(*tg.Document)
if !ok {