some fixups to grab "image" property as seen on lemmy

This commit is contained in:
Ted Unangst 2023-06-10 23:19:31 -04:00
parent 314e0bb805
commit 3b036f4975
1 changed files with 9 additions and 1 deletions

View File

@ -689,7 +689,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
case "Audio":
fallthrough
case "Image":
preferorig = true
if what == "Image" {
preferorig = true
}
fallthrough
case "Video":
fallthrough
@ -837,6 +839,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
procatt := func(att junk.Junk) {
at, _ := att.GetString("type")
mt, _ := att.GetString("mediaType")
if mt == "" {
mt = "image"
}
u, ok := att.GetString("url")
if !ok {
u, ok = att.GetString("href")
@ -890,6 +895,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
}
numatts++
}
if img, ok := obj.GetMap("image"); ok {
procatt(img)
}
if preferorig {
atts, _ := obj.GetArray("url")
for _, atti := range atts {