crawl up reply chain looking for oneups

master
Ted Unangst 6 years ago
parent 02f1ae8221
commit a1445cb118

@ -409,6 +409,31 @@ func newphone(a []string, obj map[string]interface{}) []string {
}
func xonkxonk(user *WhatAbout, item interface{}) *Honk {
depth := 0
maxdepth := 4
var xonkxonkfn func(item interface{}) *Honk
saveoneup := func(xid string) {
log.Printf("getting oneup: %s", xid)
if depth >= maxdepth {
log.Printf("in too deep")
return
}
obj, err := GetJunk(xid)
if err != nil {
log.Printf("error getting oneup: %s", err)
return
}
depth++
xonk := xonkxonkfn(obj)
if needxonk(user, xonk) {
xonk.UserID = user.ID
savexonk(user, xonk)
}
depth--
}
xonkxonkfn = func(item interface{}) *Honk {
// id, _ := jsongetstring(item, "id")
what, _ := jsongetstring(item, "type")
dt, _ := jsongetstring(item, "published")
@ -437,6 +462,9 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
case "Create":
obj, _ = jsongetmap(item, "object")
what = "honk"
case "Note":
obj = item.(map[string]interface{})
what = "honk"
case "Delete":
obj, _ = jsongetmap(item, "object")
rid, _ = jsongetstring(item, "object")
@ -445,10 +473,13 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
log.Printf("unknown activity: %s", what)
return nil
}
who, _ := jsongetstring(item, "actor")
var xonk Honk
who, _ := jsongetstring(item, "actor")
if obj != nil {
if who == "" {
who, _ = jsongetstring(obj, "attributedTo")
}
ot, _ := jsongetstring(obj, "type")
url, _ = jsongetstring(obj, "url")
if ot == "Note" || ot == "Article" {
@ -469,6 +500,9 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
}
if what == "honk" && rid != "" {
what = "tonk"
if needxonkid(user, rid) {
saveoneup(rid)
}
}
}
if ot == "Tombstone" {
@ -522,6 +556,9 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
xonk.Convoy = convoy
return &xonk
}
return xonkxonkfn(item)
}
func rubadubdub(user *WhatAbout, req map[string]interface{}) {

Loading…
Cancel
Save