finish up some hfcs matching work

This commit is contained in:
Ted Unangst 2019-10-04 21:47:27 -04:00
parent 5672db2380
commit 50e43569e4
2 changed files with 44 additions and 16 deletions

View File

@ -203,7 +203,7 @@ func iszonked(userid int64, xid string) bool {
} }
func needxonk(user *WhatAbout, x *Honk) bool { func needxonk(user *WhatAbout, x *Honk) bool {
if rejectnote(x) { if rejectxonk(x) {
log.Printf("not saving thumb biter? %s via %s", x.XID, x.Honker) log.Printf("not saving thumb biter? %s via %s", x.XID, x.Honker)
return false return false
} }

58
hfcs.go
View File

@ -146,31 +146,59 @@ func stealthmode(userid int64, r *http.Request) bool {
} }
// todo // todo
func matchfilter(h *Honk, filts []*Filter) bool { func matchfilter(h *Honk, f *Filter) bool {
origin := originate(h.XID) match := true
for _, f := range filts { if match && f.Actor != "" {
if f.Actor == origin || f.Actor == h.Honker { match = false
return true if f.Actor == h.Honker || f.Actor == h.Oonker {
match = true
} }
if f.Text != "" { if !match && (f.Actor == originate(h.Honker) ||
for _, d := range h.Donks { f.Actor == originate(h.Oonker) ||
if d.Desc == f.Text { f.Actor == originate(h.XID)) {
return true match = true
}
if !match && f.IncludeAudience {
for _, a := range h.Audience {
if f.Actor == a || f.Actor == originate(a) {
match = true
break
} }
} }
} }
} }
if match && f.Text != "" {
match = false
for _, d := range h.Donks {
if d.Desc == f.Text {
match = true
}
}
}
if match {
return true
}
return false
}
func rejectxonk(xonk *Honk) bool {
filts := getfilters(xonk.UserID, filtReject)
for _, f := range filts {
if matchfilter(xonk, filts) {
return true
}
}
return false return false
} }
func rejectnote(xonk *Honk) bool {
filts := getfilters(xonk.UserID, filtReject)
return matchfilter(xonk, filts)
}
func skipMedia(xonk *Honk) bool { func skipMedia(xonk *Honk) bool {
filts := getfilters(xonk.UserID, filtSkipMedia) filts := getfilters(xonk.UserID, filtSkipMedia)
return matchfilter(xonk, filts) for _, f := range filts {
if matchfilter(xonk, filts) {
return true
}
}
return false
} }
// todo // todo