rework save code to gobble up replies

This commit is contained in:
Ted Unangst 2019-09-30 23:32:10 -04:00
parent 49a2107fdb
commit e89bff3051
2 changed files with 20 additions and 36 deletions

View File

@ -343,10 +343,7 @@ func gimmexonks(user *WhatAbout, outbox string) {
if !ok { if !ok {
continue continue
} }
xonk := xonkxonk(user, obj, origin) xonksaver(user, obj, origin)
if xonk != nil {
savexonk(xonk)
}
} }
} }
} }
@ -423,35 +420,25 @@ func extractattrto(obj junk.Junk) string {
return "" return ""
} }
func consumeactivity(user *WhatAbout, j junk.Junk, origin string) { func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
xonk := xonkxonk(user, j, origin)
if xonk != nil {
savexonk(xonk)
}
}
func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
depth := 0 depth := 0
maxdepth := 10 maxdepth := 10
currenttid := "" currenttid := ""
var xonkxonkfn func(item junk.Junk, origin string) *Honk var xonkxonkfn func(item junk.Junk, origin string) *Honk
saveoneup := func(xid string) { saveonemore := func(xid string) {
log.Printf("getting oneup: %s", xid) log.Printf("getting onemore: %s", xid)
if depth >= maxdepth { if depth >= maxdepth {
log.Printf("in too deep") log.Printf("in too deep")
return return
} }
obj, err := GetJunkHardMode(xid) obj, err := GetJunkHardMode(xid)
if err != nil { if err != nil {
log.Printf("error getting oneup: %s: %s", xid, err) log.Printf("error getting onemore: %s: %s", xid, err)
return return
} }
depth++ depth++
xonk := xonkxonkfn(obj, originate(xid)) xonkxonkfn(obj, originate(xid))
if xonk != nil {
savexonk(xonk)
}
depth-- depth--
} }
@ -754,6 +741,7 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
xonk.Noise = content xonk.Noise = content
xonk.Precis = precis xonk.Precis = precis
xonk.Format = "html" xonk.Format = "html"
xonk.Convoy = convoy
if isUpdate { if isUpdate {
log.Printf("something has changed! %s", xonk.XID) log.Printf("something has changed! %s", xonk.XID)
@ -769,13 +757,10 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
prev.Onts = xonk.Onts prev.Onts = xonk.Onts
prev.Place = xonk.Place prev.Place = xonk.Place
updatehonk(prev) updatehonk(prev)
return nil } else if needxonk(user, &xonk) {
}
if needxonk(user, &xonk) {
if rid != "" { if rid != "" {
if needxonkid(user, rid) { if needxonkid(user, rid) {
saveoneup(rid) saveonemore(rid)
} }
if convoy == "" { if convoy == "" {
xx := getxonk(user.ID, rid) xx := getxonk(user.ID, rid)
@ -787,16 +772,16 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
if convoy == "" { if convoy == "" {
convoy = currenttid convoy = currenttid
} }
xonk.Convoy = convoy savexonk(&xonk)
}
for _, replid := range replies { for _, replid := range replies {
if needxonkid(user, replid) { if needxonkid(user, replid) {
log.Printf("missing a reply: %s", replid) log.Printf("missing a reply: %s", replid)
saveonemore(replid)
} }
} }
return &xonk return &xonk
} }
return nil
}
return xonkxonkfn(item, origin) return xonkxonkfn(item, origin)
} }

7
web.go
View File

@ -336,7 +336,7 @@ func inbox(w http.ResponseWriter, r *http.Request) {
case "Question": case "Question":
return return
case "Note": case "Note":
go consumeactivity(user, j, origin) go xonksaver(user, j, origin)
return return
} }
} }
@ -369,7 +369,7 @@ func inbox(w http.ResponseWriter, r *http.Request) {
} }
} }
default: default:
go consumeactivity(user, j, origin) go xonksaver(user, j, origin)
} }
} }
@ -396,11 +396,10 @@ func ximport(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/h?xid="+url.QueryEscape(xid), http.StatusSeeOther) http.Redirect(w, r, "/h?xid="+url.QueryEscape(xid), http.StatusSeeOther)
return return
} }
xonk := xonkxonk(user, j, originate(xid)) xonk := xonksaver(user, j, originate(xid))
convoy := "" convoy := ""
if xonk != nil { if xonk != nil {
convoy = xonk.Convoy convoy = xonk.Convoy
savexonk(xonk)
} }
http.Redirect(w, r, "/t?c="+url.QueryEscape(convoy), http.StatusSeeOther) http.Redirect(w, r, "/t?c="+url.QueryEscape(convoy), http.StatusSeeOther)
} }