diff --git a/activity.go b/activity.go index c44e5aa..2f53296 100644 --- a/activity.go +++ b/activity.go @@ -203,7 +203,7 @@ func iszonked(userid int64, xid string) 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) return false } diff --git a/hfcs.go b/hfcs.go index 9389eec..31606d1 100644 --- a/hfcs.go +++ b/hfcs.go @@ -146,31 +146,59 @@ func stealthmode(userid int64, r *http.Request) bool { } // todo -func matchfilter(h *Honk, filts []*Filter) bool { - origin := originate(h.XID) - for _, f := range filts { - if f.Actor == origin || f.Actor == h.Honker { - return true +func matchfilter(h *Honk, f *Filter) bool { + match := true + if match && f.Actor != "" { + match = false + if f.Actor == h.Honker || f.Actor == h.Oonker { + match = true } - if f.Text != "" { - for _, d := range h.Donks { - if d.Desc == f.Text { - return true + if !match && (f.Actor == originate(h.Honker) || + f.Actor == originate(h.Oonker) || + f.Actor == originate(h.XID)) { + 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 } -func rejectnote(xonk *Honk) bool { - filts := getfilters(xonk.UserID, filtReject) - return matchfilter(xonk, filts) -} - func skipMedia(xonk *Honk) bool { filts := getfilters(xonk.UserID, filtSkipMedia) - return matchfilter(xonk, filts) + for _, f := range filts { + if matchfilter(xonk, filts) { + return true + } + } + return false } // todo