don't go down if we're going up

This commit is contained in:
Ted Unangst 2019-10-01 00:01:45 -04:00
parent e89bff3051
commit 16212d9dab
1 changed files with 16 additions and 5 deletions

View File

@ -424,6 +424,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
depth := 0 depth := 0
maxdepth := 10 maxdepth := 10
currenttid := "" currenttid := ""
goingup := 0
var xonkxonkfn func(item junk.Junk, origin string) *Honk var xonkxonkfn func(item junk.Junk, origin string) *Honk
saveonemore := func(xid string) { saveonemore := func(xid string) {
@ -712,7 +713,13 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
xonk.Onts = oneofakind(xonk.Onts) xonk.Onts = oneofakind(xonk.Onts)
replyobj, ok := obj.GetMap("replies") replyobj, ok := obj.GetMap("replies")
if ok { if ok {
items, _ := replyobj.GetArray("items") items, ok := replyobj.GetArray("items")
if !ok {
first, ok := replyobj.GetMap("first")
if ok {
items, _ = first.GetArray("items")
}
}
for _, repl := range items { for _, repl := range items {
s, ok := repl.(string) s, ok := repl.(string)
if ok { if ok {
@ -760,7 +767,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
} else if needxonk(user, &xonk) { } else if needxonk(user, &xonk) {
if rid != "" { if rid != "" {
if needxonkid(user, rid) { if needxonkid(user, rid) {
goingup++
saveonemore(rid) saveonemore(rid)
goingup--
} }
if convoy == "" { if convoy == "" {
xx := getxonk(user.ID, rid) xx := getxonk(user.ID, rid)
@ -774,10 +783,12 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
} }
savexonk(&xonk) savexonk(&xonk)
} }
for _, replid := range replies { if goingup == 0 {
if needxonkid(user, replid) { for _, replid := range replies {
log.Printf("missing a reply: %s", replid) if needxonkid(user, replid) {
saveonemore(replid) log.Printf("missing a reply: %s", replid)
saveonemore(replid)
}
} }
} }
return &xonk return &xonk