diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-27 05:09:19 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-27 05:09:19 +0300 |
commit | 6da0fd56fff386f19ae982cc02c8f0996c51e2f1 (patch) | |
tree | f8e491d6bf2a77655e74b0523e460c514425cd4f /xmpp/handlers.go | |
parent | 02444d7a044fad74414e7d55905ab5a13df61aae (diff) |
Force downloading the chat photo when vCard is requested
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r-- | xmpp/handlers.go | 11 |
1 files changed, 11 insertions, 0 deletions
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()) } } } |