all repos — honk @ 0ab13b622ea0644ecd1f2fcb87248d69cb850e26

my fork of honk

allow object type field to be an array
Ted Unangst tedu@tedunangst.com
Mon, 24 May 2021 18:28:37 -0400
commit

0ab13b622ea0644ecd1f2fcb87248d69cb850e26

parent

d96bb9376fe1846298c700baef403a002c1762fb

1 files changed, 14 insertions(+), 1 deletions(-)

jump to
M activity.goactivity.go

@@ -451,6 +451,19 @@ }

return "" } +func firstofmany(obj junk.Junk, key string) string { + if val, _ := obj.GetString(key); val != "" { + return val + } + if arr, _ := obj.GetArray(key); len(arr) > 0 { + val, ok := arr[0].(string) + if ok { + return val + } + } + return "" +} + func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { depth := 0 maxdepth := 10

@@ -476,7 +489,7 @@ }

xonkxonkfn = func(item junk.Junk, origin string, isUpdate bool) *Honk { id, _ := item.GetString("id") - what, _ := item.GetString("type") + what := firstofmany(item, "type") dt, ok := item.GetString("published") if !ok { dt = time.Now().Format(time.RFC3339)