allow object type field to be an array
This commit is contained in:
parent
74525482cc
commit
6ffec8f58a
15
activity.go
15
activity.go
|
@ -451,6 +451,19 @@ func extractattrto(obj junk.Junk) string {
|
||||||
return ""
|
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 {
|
func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
depth := 0
|
depth := 0
|
||||||
maxdepth := 10
|
maxdepth := 10
|
||||||
|
@ -476,7 +489,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
|
|
||||||
xonkxonkfn = func(item junk.Junk, origin string, isUpdate bool) *Honk {
|
xonkxonkfn = func(item junk.Junk, origin string, isUpdate bool) *Honk {
|
||||||
id, _ := item.GetString("id")
|
id, _ := item.GetString("id")
|
||||||
what, _ := item.GetString("type")
|
what := firstofmany(item, "type")
|
||||||
dt, ok := item.GetString("published")
|
dt, ok := item.GetString("published")
|
||||||
if !ok {
|
if !ok {
|
||||||
dt = time.Now().Format(time.RFC3339)
|
dt = time.Now().Format(time.RFC3339)
|
||||||
|
|
Loading…
Reference in New Issue