all repos — honk @ d193c8ad303617ee7476cd12eb604c96bc377cd3

my fork of honk

rework save code to gobble up replies
Ted Unangst tedu@tedunangst.com
Mon, 30 Sep 2019 23:32:10 -0400
commit

d193c8ad303617ee7476cd12eb604c96bc377cd3

parent

bca0a79cda18856f16550cc6ab326379e7ebfaf7

2 files changed, 19 insertions(+), 35 deletions(-)

jump to
M activity.goactivity.go

@@ -343,10 +343,7 @@ obj, ok := item.(junk.Junk)

if !ok { continue } - xonk := xonkxonk(user, obj, origin) - if xonk != nil { - savexonk(xonk) - } + xonksaver(user, obj, origin) } } }

@@ -423,35 +420,25 @@ }

return "" } -func consumeactivity(user *WhatAbout, j junk.Junk, origin string) { - xonk := xonkxonk(user, j, origin) - if xonk != nil { - savexonk(xonk) - } -} - -func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk { +func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { depth := 0 maxdepth := 10 currenttid := "" var xonkxonkfn func(item junk.Junk, origin string) *Honk - saveoneup := func(xid string) { - log.Printf("getting oneup: %s", xid) + saveonemore := func(xid string) { + log.Printf("getting onemore: %s", xid) if depth >= maxdepth { log.Printf("in too deep") return } obj, err := GetJunkHardMode(xid) if err != nil { - log.Printf("error getting oneup: %s: %s", xid, err) + log.Printf("error getting onemore: %s: %s", xid, err) return } depth++ - xonk := xonkxonkfn(obj, originate(xid)) - if xonk != nil { - savexonk(xonk) - } + xonkxonkfn(obj, originate(xid)) depth-- }

@@ -754,6 +741,7 @@ xonk.URL = url

xonk.Noise = content xonk.Precis = precis xonk.Format = "html" + xonk.Convoy = convoy if isUpdate { log.Printf("something has changed! %s", xonk.XID)

@@ -769,13 +757,10 @@ prev.Donks = xonk.Donks

prev.Onts = xonk.Onts prev.Place = xonk.Place updatehonk(prev) - return nil - } - - if needxonk(user, &xonk) { + } else if needxonk(user, &xonk) { if rid != "" { if needxonkid(user, rid) { - saveoneup(rid) + saveonemore(rid) } if convoy == "" { xx := getxonk(user.ID, rid)

@@ -787,15 +772,15 @@ }

if convoy == "" { convoy = currenttid } - xonk.Convoy = convoy - for _, replid := range replies { - if needxonkid(user, replid) { - log.Printf("missing a reply: %s", replid) - } + savexonk(&xonk) + } + for _, replid := range replies { + if needxonkid(user, replid) { + log.Printf("missing a reply: %s", replid) + saveonemore(replid) } - return &xonk } - return nil + return &xonk } return xonkxonkfn(item, origin)
M web.goweb.go

@@ -336,7 +336,7 @@ return

case "Question": return case "Note": - go consumeactivity(user, j, origin) + go xonksaver(user, j, origin) return } }

@@ -369,7 +369,7 @@ log.Printf("unknown undo: %s", what)

} } default: - go consumeactivity(user, j, origin) + go xonksaver(user, j, origin) } }

@@ -396,11 +396,10 @@ gimmexonks(user, outbox)

http.Redirect(w, r, "/h?xid="+url.QueryEscape(xid), http.StatusSeeOther) return } - xonk := xonkxonk(user, j, originate(xid)) + xonk := xonksaver(user, j, originate(xid)) convoy := "" if xonk != nil { convoy = xonk.Convoy - savexonk(xonk) } http.Redirect(w, r, "/t?c="+url.QueryEscape(convoy), http.StatusSeeOther) }