fast skip announce from rejected domains
This commit is contained in:
parent
50fb0d5e09
commit
eb3ea156a6
10
activity.go
10
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)
|
||||
|
|
15
hfcs.go
15
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
|
||||
|
|
Loading…
Reference in New Issue