allow filtering of replies

This commit is contained in:
Ted Unangst 2023-03-15 15:26:46 -04:00
parent af2deab137
commit 858ce2f291
4 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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 ||

View File

@ -20,6 +20,8 @@ Honk Filtering and Censorship System
<input tabindex=1 type="checkbox" id="incaud" name="incaud" value="yes"><span></span></label></span>
<p><label for="filttext">text matches:</label><br>
<input tabindex=1 type="text" name="filttext" value="" autocomplete=off>
<p><span><label class=button for="isreply">is reply:
<input tabindex=1 type="checkbox" id="isreply" name="isreply" value="yes"><span></span></label></span>
<p><span><label class=button for="isannounce">is announce:
<input tabindex=1 type="checkbox" id="isannounce" name="isannounce" value="yes"><span></span></label></span>
<p><label for="announceof">announce of:</label><br>
@ -54,6 +56,7 @@ Honk Filtering and Censorship System
{{ with .Notes }}<p>Notes: {{ . }}{{ end }}
<p>Date: {{ .Date.Format "2006-01-02" }}
{{ with .Actor }}<p>Who: {{ . }}{{ end }} {{ with .IncludeAudience }} (inclusive) {{ end }}
{{ if .IsReply }}<p>Reply: y{{ end }}
{{ if .IsAnnounce }}<p>Announce: {{ .AnnounceOf }}{{ end }}
{{ with .Text }}<p>Text: {{ . }}{{ end }}
<p>Actions: {{ range .Actions }} {{ . }} {{ end }}

1
web.go
View File

@ -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"