|
|
|
@ -214,21 +214,29 @@ func stealthmode(userid int64, r *http.Request) bool {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func matchfilter(h *Honk, f *Filter) bool {
|
|
|
|
|
return matchfilterX(h, f) != ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func matchfilterX(h *Honk, f *Filter) string {
|
|
|
|
|
rv := ""
|
|
|
|
|
match := true
|
|
|
|
|
if match && f.Actor != "" {
|
|
|
|
|
match = false
|
|
|
|
|
if f.Actor == h.Honker || f.Actor == h.Oonker {
|
|
|
|
|
match = true
|
|
|
|
|
rv = f.Actor
|
|
|
|
|
}
|
|
|
|
|
if !match && (f.Actor == originate(h.Honker) ||
|
|
|
|
|
f.Actor == originate(h.Oonker) ||
|
|
|
|
|
f.Actor == originate(h.XID)) {
|
|
|
|
|
match = true
|
|
|
|
|
rv = f.Actor
|
|
|
|
|
}
|
|
|
|
|
if !match && f.IncludeAudience {
|
|
|
|
|
for _, a := range h.Audience {
|
|
|
|
|
if f.Actor == a || f.Actor == originate(a) {
|
|
|
|
|
match = true
|
|
|
|
|
rv = f.Actor
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -239,23 +247,33 @@ func matchfilter(h *Honk, f *Filter) bool {
|
|
|
|
|
if (f.AnnounceOf == "" && h.Oonker != "") || f.AnnounceOf == h.Oonker ||
|
|
|
|
|
f.AnnounceOf == originate(h.Oonker) {
|
|
|
|
|
match = true
|
|
|
|
|
rv += " announce"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if match && f.Text != "" {
|
|
|
|
|
match = false
|
|
|
|
|
re := f.re_text
|
|
|
|
|
if re.MatchString(h.Noise) || re.MatchString(h.Precis) {
|
|
|
|
|
match = true
|
|
|
|
|
m := re.FindString(h.Precis)
|
|
|
|
|
if m == "" {
|
|
|
|
|
m = re.FindString(h.Noise)
|
|
|
|
|
}
|
|
|
|
|
if !match {
|
|
|
|
|
if m == "" {
|
|
|
|
|
for _, d := range h.Donks {
|
|
|
|
|
if re.MatchString(d.Desc) {
|
|
|
|
|
match = true
|
|
|
|
|
m = re.FindString(d.Desc)
|
|
|
|
|
if m != "" {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if m != "" {
|
|
|
|
|
match = true
|
|
|
|
|
rv = m
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if match {
|
|
|
|
|
return rv
|
|
|
|
|
}
|
|
|
|
|
return match
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func rejectxonk(xonk *Honk) bool {
|
|
|
|
@ -282,11 +300,7 @@ func skipMedia(xonk *Honk) bool {
|
|
|
|
|
func unsee(userid int64, h *Honk) {
|
|
|
|
|
filts := getfilters(userid, filtCollapse)
|
|
|
|
|
for _, f := range filts {
|
|
|
|
|
if matchfilter(h, f) {
|
|
|
|
|
bad := f.Text
|
|
|
|
|
if f.Actor != "" {
|
|
|
|
|
bad = f.Actor
|
|
|
|
|
}
|
|
|
|
|
if bad := matchfilterX(h, f); bad != "" {
|
|
|
|
|
if h.Precis == "" {
|
|
|
|
|
h.Precis = bad
|
|
|
|
|
}
|
|
|
|
|