From 16212d9dabd707b79e8c6fca9d1e667a3bf8d318 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 1 Oct 2019 00:01:45 -0400 Subject: [PATCH] don't go down if we're going up --- activity.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/activity.go b/activity.go index cda8f28..cee90e1 100644 --- a/activity.go +++ b/activity.go @@ -424,6 +424,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { depth := 0 maxdepth := 10 currenttid := "" + goingup := 0 var xonkxonkfn func(item junk.Junk, origin string) *Honk saveonemore := func(xid string) { @@ -712,7 +713,13 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { xonk.Onts = oneofakind(xonk.Onts) replyobj, ok := obj.GetMap("replies") 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 { s, ok := repl.(string) if ok { @@ -760,7 +767,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { } else if needxonk(user, &xonk) { if rid != "" { if needxonkid(user, rid) { + goingup++ saveonemore(rid) + goingup-- } if convoy == "" { xx := getxonk(user.ID, rid) @@ -774,10 +783,12 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { } savexonk(&xonk) } - for _, replid := range replies { - if needxonkid(user, replid) { - log.Printf("missing a reply: %s", replid) - saveonemore(replid) + if goingup == 0 { + for _, replid := range replies { + if needxonkid(user, replid) { + log.Printf("missing a reply: %s", replid) + saveonemore(replid) + } } } return &xonk