all repos — honk @ 187831666d8f9c61de81da955a50f630bc566361

my fork of honk

don't fetch bonks if we already have them
Ted Unangst tedu@tedunangst.com
Thu, 25 Apr 2019 01:18:39 -0400
commit

187831666d8f9c61de81da955a50f630bc566361

parent

5919024da1616a2634b0a2bb121d21076f604350

2 files changed, 18 insertions(+), 8 deletions(-)

jump to
M activity.goactivity.go

@@ -227,14 +227,21 @@ return &donk

} func needxonk(user *WhatAbout, x *Honk) bool { - if strings.HasPrefix(x.XID, user.URL+"/h/") { + if x == nil { return false } if x.What == "eradicate" { return true } - row := stmtFindXonk.QueryRow(user.ID, x.XID) - err := row.Scan(&x.ID) + return needxonkid(user, x.XID) +} +func needxonkid(user *WhatAbout, xid string) bool { + if strings.HasPrefix(xid, user.URL+"/h/") { + return false + } + row := stmtFindXonk.QueryRow(user.ID, xid) + var id int64 + err := row.Scan(&id) if err == nil { return false }

@@ -361,8 +368,8 @@ items, _ = jsongetarray(j, "orderedItems")

} for _, item := range items { - xonk := xonkxonk(item) - if xonk != nil && needxonk(user, xonk) { + xonk := xonkxonk(user, item) + if needxonk(user, xonk) { xonk.UserID = user.ID savexonk(user, xonk) }

@@ -401,7 +408,7 @@ }

return a } -func xonkxonk(item interface{}) *Honk { +func xonkxonk(user *WhatAbout, item interface{}) *Honk { // id, _ := jsongetstring(item, "id") what, _ := jsongetstring(item, "type") dt, _ := jsongetstring(item, "published")

@@ -415,6 +422,9 @@ switch what {

case "Announce": xid, ok = jsongetstring(item, "object") if ok { + if !needxonkid(user, xid) { + return nil + } log.Printf("getting bonk: %s", xid) obj, err = GetJunk(xid) if err != nil {
M honk.gohonk.go

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

} } default: - xonk := xonkxonk(j) - if xonk != nil && needxonk(user, xonk) { + xonk := xonkxonk(user, j) + if needxonk(user, xonk) { xonk.UserID = user.ID savexonk(user, xonk) }