diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-06-25 23:58:15 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-06-25 23:58:15 +0300 |
commit | 493c49cde5b5d51f3dd9bc6b1a925b0fd2a1c52f (patch) | |
tree | 837c7d87175fc9bee033094650548eb06e26bc96 /xmpp/handlers.go | |
parent | ebc2f244d75edf338142f9f023d984b3c9605a67 (diff) |
Same robust file retrieval for calculating avatar SHA1 and Base64
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r-- | xmpp/handlers.go | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go index 4f048fb..ee1db21 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -5,7 +5,6 @@ import ( "encoding/base64" "github.com/pkg/errors" "io" - "os" "strconv" "strings" @@ -252,17 +251,7 @@ func handleGetVcardTempIq(s xmpp.Sender, iq *stanza.IQ) { vcard.Fn.Text = chat.Title 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) - } - } - + file, path, err := session.OpenPhotoFile(chat.Photo.Small, 32) if err == nil { defer file.Close() |