fix avatars

This commit is contained in:
2026-05-02 06:56:08 +01:00
parent 5bcf0eda0b
commit 58c7165ce5
3 changed files with 48 additions and 31 deletions
+12 -5
View File
@@ -10,7 +10,6 @@ import (
"github.com/diamondburned/gotk4/pkg/glib/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
"github.com/google/uuid"
"github.com/jacoblockett/sanitizefilename"
"github.com/jasonlovesdoggo/gopen"
"gosrc.io/xmpp/stanza"
"mellium.im/xmpp/jid"
@@ -305,11 +304,15 @@ func getAvatar(j, hash string) *gtk.Image { // TODO: This function probably shou
return createIdenticon(j)
}
hash = filepath.Join(p, sanitizefilename.Sanitize(hash))
hash = filepath.Join(p, hash)
_, err = os.ReadFile(hash)
if err == nil {
i := newImageFromPath(hash)
i, err := newImageFromPath(hash)
if err != nil {
invalidImages[oghash] = true
return createIdenticon(j)
}
i.AddCSSClass(loadedConfig.CVD.String() + "_CVD")
return i
}
@@ -318,7 +321,7 @@ func getAvatar(j, hash string) *gtk.Image { // TODO: This function probably shou
Type: "get",
From: clientroot.Session.BindJid,
To: j,
Id: "vc2",
Id: uuid.New().String(),
Lang: "en",
})
@@ -356,7 +359,11 @@ func getAvatar(j, hash string) *gtk.Image { // TODO: This function probably shou
panic(err)
}
i := newImageFromPath(hash)
i, err := newImageFromPath(hash)
if err != nil {
invalidImages[oghash] = true
return createIdenticon(j)
}
i.AddCSSClass(loadedConfig.CVD.String() + "_CVD")
return i
}