From aea6401d7561567e6e7ab2aef06183a9c9c2509c Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 5 Aug 2020 15:33:27 -0400 Subject: [PATCH] option to mention all in replies --- docs/changelog.txt | 2 ++ fun.go | 20 +++++++++++++++++++- honk.go | 2 ++ views/account.html | 3 +++ views/honk.html | 2 +- views/honkpage.js | 2 +- web.go | 5 +++++ 7 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7fc6c7a..9533cb5 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -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. diff --git a/fun.go b/fun.go index 92a523e..b81f427 100644 --- a/fun.go +++ b/fun.go @@ -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 diff --git a/honk.go b/honk.go index c87a83d..97b21d8 100644 --- a/honk.go +++ b/honk.go @@ -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 diff --git a/views/account.html b/views/account.html index a23410d..9aa53ce 100644 --- a/views/account.html +++ b/views/account.html @@ -12,6 +12,9 @@

+

+ +

diff --git a/views/honk.html b/views/honk.html index 1a88e04..436dc74 100644 --- a/views/honk.html +++ b/views/honk.html @@ -106,7 +106,7 @@ in reply to: {{ .RID }} {{ else }} {{ end }} - + diff --git a/views/honkpage.js b/views/honkpage.js index e810c9f..ca1ef22 100644 --- a/views/honkpage.js +++ b/views/honkpage.js @@ -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 = "" diff --git a/web.go b/web.go index c2ac7ee..4468a99 100644 --- a/web.go +++ b/web.go @@ -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 {