all repos — honk @ 303fa380ccb67edb416ed1dfb9b8640774a3f53c

my fork of honk

fast skip announce from rejected domains
Ted Unangst tedu@tedunangst.com
Sun, 08 Dec 2019 19:09:56 -0500
commit

303fa380ccb67edb416ed1dfb9b8640774a3f53c

parent

877cba0043b80835ffbc824a86d470101598a1b9

2 files changed, 20 insertions(+), 5 deletions(-)

jump to
M activity.goactivity.go

@@ -241,14 +241,20 @@ return false

} return needxonkid(user, x.XID) } +func needbonkid(user *WhatAbout, xid string) bool { + return needxonkidX(user, xid, true) +} func needxonkid(user *WhatAbout, xid string) bool { + return needxonkidX(user, xid, false) +} +func needxonkidX(user *WhatAbout, xid string, isannounce bool) bool { if !strings.HasPrefix(xid, "https://") { return false } if strings.HasPrefix(xid, user.URL+"/") { return false } - if rejectorigin(user.ID, xid) { + if rejectorigin(user.ID, xid, isannounce) { return false } if iszonked(user.ID, xid) {

@@ -504,7 +510,7 @@ xid, _ = obj.GetString("id")

} else { xid, _ = item.GetString("object") } - if !needxonkid(user, xid) { + if !needbonkid(user, xid) { return nil } log.Printf("getting bonk: %s", xid)
M hfcs.gohfcs.go

@@ -169,14 +169,23 @@ }

return nil } -func rejectorigin(userid int64, origin string) bool { +func rejectorigin(userid int64, origin string, isannounce bool) bool { if o := originate(origin); o != "" { origin = o } filts := getfilters(userid, filtReject) for _, f := range filts { - if f.IsAnnounce || f.Text != "" { + if f.Text != "" { continue + } + if f.IsAnnounce { + if !isannounce { + continue + } + if f.AnnounceOf == origin { + log.Printf("rejecting announce: %s", origin) + return true + } } if f.Actor == origin { log.Printf("rejecting origin: %s", origin)

@@ -205,7 +214,7 @@ func stealthmode(userid int64, r *http.Request) bool {

agent := r.UserAgent() agent = originate(agent) if agent != "" { - fake := rejectorigin(userid, agent) + fake := rejectorigin(userid, agent, false) if fake { log.Printf("faking 404 for %s", agent) return true