From 858ce2f291332f29fbb2fe3d933e598a7c448e94 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 15 Mar 2023 15:26:46 -0400 Subject: [PATCH] allow filtering of replies --- docs/hfcs.1 | 2 ++ hfcs.go | 8 ++++++++ views/hfcs.html | 3 +++ web.go | 1 + 4 files changed, 14 insertions(+) diff --git a/docs/hfcs.1 b/docs/hfcs.1 index 5a7af15..9b1cf88 100644 --- a/docs/hfcs.1 +++ b/docs/hfcs.1 @@ -52,6 +52,8 @@ fields as well. Regular expression match against the post .Fa content . The special value of "." will match any post with a summary only. +.It Ar is reply +A reply to another post. .It Ar is announce Is announced (shared). .It Ar announce of diff --git a/hfcs.go b/hfcs.go index ec82ecc..d51e541 100644 --- a/hfcs.go +++ b/hfcs.go @@ -33,6 +33,7 @@ type Filter struct { IncludeAudience bool `json:",omitempty"` Text string `json:",omitempty"` re_text *regexp.Regexp + IsReply bool `json:",omitempty"` IsAnnounce bool `json:",omitempty"` AnnounceOf string `json:",omitempty"` Reject bool `json:",omitempty"` @@ -306,6 +307,13 @@ func matchfilterX(h *Honk, f *Filter) string { } } } + if match && f.IsReply { + match = false + if h.RID != "" { + match = true + rv += " reply" + } + } if match && f.IsAnnounce { match = false if (f.AnnounceOf == "" && h.Oonker != "") || f.AnnounceOf == h.Oonker || diff --git a/views/hfcs.html b/views/hfcs.html index b6f436d..8b2e534 100644 --- a/views/hfcs.html +++ b/views/hfcs.html @@ -20,6 +20,8 @@ Honk Filtering and Censorship System


+


@@ -54,6 +56,7 @@ Honk Filtering and Censorship System {{ with .Notes }}

Notes: {{ . }}{{ end }}

Date: {{ .Date.Format "2006-01-02" }} {{ with .Actor }}

Who: {{ . }}{{ end }} {{ with .IncludeAudience }} (inclusive) {{ end }} +{{ if .IsReply }}

Reply: y{{ end }} {{ if .IsAnnounce }}

Announce: {{ .AnnounceOf }}{{ end }} {{ with .Text }}

Text: {{ . }}{{ end }}

Actions: {{ range .Actions }} {{ . }} {{ end }} diff --git a/web.go b/web.go index e883f73..7f5f30f 100644 --- a/web.go +++ b/web.go @@ -2004,6 +2004,7 @@ func savehfcs(w http.ResponseWriter, r *http.Request) { filt.Actor = strings.TrimSpace(r.FormValue("actor")) filt.IncludeAudience = r.FormValue("incaud") == "yes" filt.Text = strings.TrimSpace(r.FormValue("filttext")) + filt.IsReply = r.FormValue("isreply") == "yes" filt.IsAnnounce = r.FormValue("isannounce") == "yes" filt.AnnounceOf = strings.TrimSpace(r.FormValue("announceof")) filt.Reject = r.FormValue("doreject") == "yes"