From 6da0fd56fff386f19ae982cc02c8f0996c51e2f1 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Wed, 26 Jan 2022 21:09:19 -0500 Subject: Force downloading the chat photo when vCard is requested --- xmpp/handlers.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'xmpp') diff --git a/xmpp/handlers.go b/xmpp/handlers.go index 07c30ec..6770e3a 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -236,6 +236,15 @@ func handleGetVcardTempIq(s xmpp.Sender, iq *stanza.IQ) { if chat.Photo != nil { path := chat.Photo.Small.Local.Path file, err := os.Open(path) + // obtain the photo right now if still not downloaded + if err != nil && !chat.Photo.Small.Local.IsDownloadingCompleted { + tdFile, tdErr := session.DownloadFile(chat.Photo.Small.Id, 32, true) + if tdErr == nil { + path = tdFile.Local.Path + file, err = os.Open(path) + } + } + if err == nil { defer file.Close() @@ -250,6 +259,8 @@ func handleGetVcardTempIq(s xmpp.Sender, iq *stanza.IQ) { } } else if path != "" { log.Errorf("Photo does not exist: %v", path) + } else { + log.Errorf("PHOTO: %#v", err.Error()) } } } -- cgit v1.2.3