more robust parsing of attachment json

This commit is contained in:
Ted Unangst 2020-05-15 00:18:40 -04:00
parent 164a295401
commit 5acf6ef5ce
1 changed files with 8 additions and 1 deletions

View File

@ -725,7 +725,14 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
mt, _ := att.GetString("mediaType")
u, ok := att.GetString("url")
if !ok {
if uu, ok := att.GetMap("url"); ok {
if ua, ok := att.GetArray("url"); ok && len(ua) > 0 {
u, ok = ua[0].(string)
if !ok {
if uu, ok := ua[0].(junk.Junk); ok {
u, _ = uu.GetString("href")
}
}
} else if uu, ok := att.GetMap("url"); ok {
u, _ = uu.GetString("href")
}
}