Fix calculating avatar Base64

This commit is contained in:
Bohdan Horbeshko 2022-06-25 16:58:36 -04:00
parent 493c49cde5
commit 3a43c6223f

View file

@ -258,11 +258,12 @@ func handleGetVcardTempIq(s xmpp.Sender, iq *stanza.IQ) {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
binval := base64.NewEncoder(base64.StdEncoding, buf) binval := base64.NewEncoder(base64.StdEncoding, buf)
_, err = io.Copy(binval, file) _, err = io.Copy(binval, file)
binval.Close()
if err == nil { if err == nil {
vcard.Photo.Type.Text = "image/jpeg" vcard.Photo.Type.Text = "image/jpeg"
vcard.Photo.Binval.Text = buf.String() vcard.Photo.Binval.Text = buf.String()
} else { } else {
log.Errorf("Error calculating hash: %v", path) log.Errorf("Error calculating base64: %v", path)
} }
} else if path != "" { } else if path != "" {
log.Errorf("Photo does not exist: %v", path) log.Errorf("Photo does not exist: %v", path)