directdownload,tomatrix: add missing nil checks
This commit is contained in:
@@ -191,10 +191,10 @@ func (tc *TelegramConnector) Download(ctx context.Context, mediaID networkid.Med
|
|||||||
chatFull, ok := fullChat.FullChat.(*tg.ChatFull)
|
chatFull, ok := fullChat.FullChat.(*tg.ChatFull)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("full chat is %T not *tg.ChatFull", fullChat.FullChat)
|
return nil, fmt.Errorf("full chat is %T not *tg.ChatFull", fullChat.FullChat)
|
||||||
}
|
} else if chatFull.ChatPhoto == nil {
|
||||||
|
// FIXME: these 2 are basically not found errors
|
||||||
// FIXME: this is basically a not found error
|
return nil, fmt.Errorf("photo not found on chat")
|
||||||
if photoID := chatFull.ChatPhoto.GetID(); photoID != info.ID {
|
} else if photoID := chatFull.ChatPhoto.GetID(); photoID != info.ID {
|
||||||
return nil, fmt.Errorf("photo id mismatch: %d != %d", photoID, info.ID)
|
return nil, fmt.Errorf("photo id mismatch: %d != %d", photoID, info.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -400,8 +400,12 @@ func (c *TelegramClient) convertMediaRequiringUpload(ctx context.Context, portal
|
|||||||
} else {
|
} else {
|
||||||
content.Body = "image"
|
content.Body = "image"
|
||||||
}
|
}
|
||||||
telegramMediaID = msgMedia.Photo.GetID()
|
photo, ok := msgMedia.Photo.(*tg.Photo)
|
||||||
mediaTransferer = transferer.WithPhoto(msgMedia.Photo)
|
if !ok {
|
||||||
|
return nil, nil, fmt.Errorf("unrecognized photo type %T", msgMedia.Photo)
|
||||||
|
}
|
||||||
|
telegramMediaID = photo.GetID()
|
||||||
|
mediaTransferer = transferer.WithPhoto(photo)
|
||||||
case *tg.MessageMediaDocument:
|
case *tg.MessageMediaDocument:
|
||||||
document, ok := msgMedia.Document.(*tg.Document)
|
document, ok := msgMedia.Document.(*tg.Document)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user