crawl up reply chain looking for oneups
This commit is contained in:
parent
02f1ae8221
commit
a1445cb118
39
activity.go
39
activity.go
|
@ -409,6 +409,31 @@ func newphone(a []string, obj map[string]interface{}) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
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")
|
// id, _ := jsongetstring(item, "id")
|
||||||
what, _ := jsongetstring(item, "type")
|
what, _ := jsongetstring(item, "type")
|
||||||
dt, _ := jsongetstring(item, "published")
|
dt, _ := jsongetstring(item, "published")
|
||||||
|
@ -437,6 +462,9 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
case "Create":
|
case "Create":
|
||||||
obj, _ = jsongetmap(item, "object")
|
obj, _ = jsongetmap(item, "object")
|
||||||
what = "honk"
|
what = "honk"
|
||||||
|
case "Note":
|
||||||
|
obj = item.(map[string]interface{})
|
||||||
|
what = "honk"
|
||||||
case "Delete":
|
case "Delete":
|
||||||
obj, _ = jsongetmap(item, "object")
|
obj, _ = jsongetmap(item, "object")
|
||||||
rid, _ = jsongetstring(item, "object")
|
rid, _ = jsongetstring(item, "object")
|
||||||
|
@ -445,10 +473,13 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
log.Printf("unknown activity: %s", what)
|
log.Printf("unknown activity: %s", what)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
who, _ := jsongetstring(item, "actor")
|
|
||||||
|
|
||||||
var xonk Honk
|
var xonk Honk
|
||||||
|
who, _ := jsongetstring(item, "actor")
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
|
if who == "" {
|
||||||
|
who, _ = jsongetstring(obj, "attributedTo")
|
||||||
|
}
|
||||||
ot, _ := jsongetstring(obj, "type")
|
ot, _ := jsongetstring(obj, "type")
|
||||||
url, _ = jsongetstring(obj, "url")
|
url, _ = jsongetstring(obj, "url")
|
||||||
if ot == "Note" || ot == "Article" {
|
if ot == "Note" || ot == "Article" {
|
||||||
|
@ -469,6 +500,9 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
}
|
}
|
||||||
if what == "honk" && rid != "" {
|
if what == "honk" && rid != "" {
|
||||||
what = "tonk"
|
what = "tonk"
|
||||||
|
if needxonkid(user, rid) {
|
||||||
|
saveoneup(rid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ot == "Tombstone" {
|
if ot == "Tombstone" {
|
||||||
|
@ -524,6 +558,9 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
return &xonk
|
return &xonk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return xonkxonkfn(item)
|
||||||
|
}
|
||||||
|
|
||||||
func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
||||||
xid, _ := jsongetstring(req, "id")
|
xid, _ := jsongetstring(req, "id")
|
||||||
reqactor, _ := jsongetstring(req, "actor")
|
reqactor, _ := jsongetstring(req, "actor")
|
||||||
|
|
Loading…
Reference in New Issue