more robust parsing of attachment json
Ted Unangst tedu@tedunangst.com
Fri, 15 May 2020 00:18:40 -0400
1 files changed,
8 insertions(+),
1 deletions(-)
jump to
M
activity.go
→
activity.go
@@ -725,7 +725,14 @@ at, _ := att.GetString("type")
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") } }