retarget mention links to local profile

This commit is contained in:
Ted Unangst 2023-07-30 17:03:46 -04:00
parent a8aa306af4
commit d3bf2b7bc8
4 changed files with 15 additions and 3 deletions

View File

@ -2,6 +2,8 @@ changelog
=== next === next
+ Mention links locally.
+ ::: spoiler markdown + ::: spoiler markdown
+ New threaded display order. + New threaded display order.

10
fun.go
View File

@ -159,6 +159,16 @@ func reverbolate(userid int64, honks []*Honk) {
data = re_emus.ReplaceAllStringFunc(data, emuxifier) data = re_emus.ReplaceAllStringFunc(data, emuxifier)
io.WriteString(w, data) io.WriteString(w, data)
} }
if user != nil {
htf.RetargetLink = func(href string) string {
for _, m := range h.Mentions {
if href == m.Where {
return "/h?xid=" + url.QueryEscape(href)
}
}
return href
}
}
p, _ := htf.String(h.Precis) p, _ := htf.String(h.Precis)
n, _ := htf.String(h.Noise) n, _ := htf.String(h.Noise)
h.Precis = string(p) h.Precis = string(p)

2
go.mod
View File

@ -9,5 +9,5 @@ require (
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 humungus.tedunangst.com/r/go-sqlite3 v1.1.3
humungus.tedunangst.com/r/webs v0.6.66 humungus.tedunangst.com/r/webs v0.6.67
) )

4
go.sum
View File

@ -25,5 +25,5 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI= humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
humungus.tedunangst.com/r/webs v0.6.66 h1:+3cB6m1tBtO/Sc9+ggAZP7MNo76Dm66+mMWc1Kub34k= humungus.tedunangst.com/r/webs v0.6.67 h1:OO5UkQa+bHeiIrZ5IGR9JGtgGPsKsYlRJEVk1bSt+Qo=
humungus.tedunangst.com/r/webs v0.6.66/go.mod h1:03R0N9BcT49HB4TDd1YmarpbiPvPzVDm74Mk4h1hYPc= humungus.tedunangst.com/r/webs v0.6.67/go.mod h1:03R0N9BcT49HB4TDd1YmarpbiPvPzVDm74Mk4h1hYPc=