option to mention all in replies

This commit is contained in:
Ted Unangst 2020-08-05 15:33:27 -04:00
parent 4b89e0a43a
commit aea6401d75
7 changed files with 33 additions and 3 deletions

View File

@ -2,6 +2,8 @@ changelog
=== next
+ Option to mention all in replies.
+ Reduce interference between various text substitution rules.
+ Fix crash in search with extra space.

20
fun.go
View File

@ -52,6 +52,8 @@ func init() {
}
func reverbolate(userid int64, honks []*Honk) {
var user *WhatAbout
somenumberedusers.Get(userid, &user)
for _, h := range honks {
h.What += "ed"
if h.What == "tonked" {
@ -81,6 +83,22 @@ func reverbolate(userid int64, honks []*Honk) {
}
}
}
if user.Options.MentionAll {
hset := []string{"@" + h.Handle}
for _, a := range h.Audience {
if a == h.Honker {
continue
}
_, hand := handles(a)
if hand != "" {
hand = "@" + hand
hset = append(hset, hand)
}
}
h.Handles = strings.Join(hset, " ")
} else {
h.Handles = "@" + h.Handle
}
if h.URL == "" {
h.URL = h.XID
}
@ -527,7 +545,7 @@ var allhandles = cache.New(cache.Options{Filler: func(xid string) (string, bool)
// handle, handle@host
func handles(xid string) (string, string) {
if xid == "" {
if xid == "" || xid == thewholeworld || strings.HasSuffix(xid, "/followers") {
return "", ""
}
var handle string

View File

@ -52,6 +52,7 @@ type UserOptions struct {
Avatar string `json:",omitempty"`
MapLink string `json:",omitempty"`
Reaction string `json:",omitempty"`
MentionAll bool
}
type KeyInfo struct {
@ -68,6 +69,7 @@ type Honk struct {
What string
Honker string
Handle string
Handles string
Oonker string
Oondle string
XID string

View File

@ -12,6 +12,9 @@
<input tabindex=1 type="checkbox" id="skinny" name="skinny" value="skinny" {{ if .User.Options.SkinnyCSS }}checked{{ end }}><span></span>
<p><label class="button" for="omitimages">omit images:</label>
<input tabindex=1 type="checkbox" id="omitimages" name="omitimages" value="omitimages" {{ if .User.Options.OmitImages }}checked{{ end }}><span></span>
<p><label class="button" for="mentionall">mention all:</label>
<input tabindex=1 type="checkbox" id="mentionall" name="mentionall" value="mentionall" {{ if .User.Options.MentionAll }}checked{{ end }}><span></span>
<p><label class="button" for="maps">apple map links:</label>
<input tabindex=1 type="checkbox" id="maps" name="maps" value="apple" {{ if eq "apple" .User.Options.MapLink }}checked{{ end }}><span></span>
<p><label class="button" for="reaction">reaction:</label>

View File

@ -106,7 +106,7 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
{{ else }}
<button disabled>nope</button>
{{ end }}
<button onclick="return showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handle }}');"><a href="/newhonk?rid={{ .Honk.XID }}">honk back</a></button>
<button onclick="return showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handles }}');"><a href="/newhonk?rid={{ .Honk.XID }}">honk back</a></button>
<button onclick="return muteit(this, '{{ .Honk.Convoy }}');">mute</button>
<button onclick="return showelement('evenmore{{ .Honk.ID }}')">even more</button>
</div>

View File

@ -261,7 +261,7 @@ function showhonkform(elem, rid, hname) {
var ridinput = document.getElementById("ridinput")
if (rid) {
ridinput.value = rid
honknoise.value = "@" + hname + " "
honknoise.value = hname + " "
} else {
ridinput.value = ""
honknoise.value = ""

5
web.go
View File

@ -1133,6 +1133,11 @@ func saveuser(w http.ResponseWriter, r *http.Request) {
} else {
options.OmitImages = false
}
if r.FormValue("mentionall") == "mentionall" {
options.MentionAll = true
} else {
options.MentionAll = false
}
if r.FormValue("maps") == "apple" {
options.MapLink = "apple"
} else {