From eb3ea156a6b5dd4d78e78aee3a1d32c3991c7ca1 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 8 Dec 2019 19:09:56 -0500 Subject: [PATCH] fast skip announce from rejected domains --- activity.go | 10 ++++++++-- hfcs.go | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/activity.go b/activity.go index 2e61cca..578bfe5 100644 --- a/activity.go +++ b/activity.go @@ -241,14 +241,20 @@ func needxonk(user *WhatAbout, x *Honk) bool { } 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 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { } else { xid, _ = item.GetString("object") } - if !needxonkid(user, xid) { + if !needbonkid(user, xid) { return nil } log.Printf("getting bonk: %s", xid) diff --git a/hfcs.go b/hfcs.go index 6768bf2..08a36a5 100644 --- a/hfcs.go +++ b/hfcs.go @@ -169,15 +169,24 @@ func getfilters(userid int64, scope filtType) []*Filter { 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) return true @@ -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