add cc: and link: fields with dark magic to reconfigure honk objects
Ted Unangst tedu@tedunangst.com
Mon, 19 Feb 2024 00:42:10 -0500
3 files changed,
21 insertions(+),
1 deletions(-)
M
activity.go
→
activity.go
@@ -1381,7 +1381,14 @@ }
if !h.Public { jo["directMessage"] = true } - h.Noise = re_retag.ReplaceAllString(h.Noise, "") + h.Noise = re_link.ReplaceAllStringFunc(h.Noise, func(x string) string { + link := x[5:] + if link[0] == ' ' { + link = link[1:] + } + h.Link = link + return "" + }) translate(h) redoimages(h) if h.Precis != "" {@@ -1467,6 +1474,13 @@ jo["duration"] = "PT" + strings.ToUpper(t.Duration.String())
} } atts := activatedonks(h.Donks) + if h.Link != "" { + jo["type"] = "Page" + jl := junk.New() + jl["type"] = "Link" + jl["href"] = h.Link + atts = append(atts, jl) + } if len(atts) > 0 { jo["attachment"] = atts }
M
fun.go
→
fun.go
@@ -83,6 +83,7 @@ }
if local && h.What != "bonked" { h.Noise = re_retag.ReplaceAllString(h.Noise, "") h.Noise = re_memes.ReplaceAllString(h.Noise, "") + h.Noise = re_cc.ReplaceAllString(h.Noise, "") } h.Username, h.Handle = handles(h.Honker) if !local {@@ -371,6 +372,8 @@ }
honk.Donks = honk.Donks[:j] honk.Noise = re_memes.ReplaceAllString(honk.Noise, "") + honk.Noise = re_retag.ReplaceAllString(honk.Noise, "") + honk.Noise = re_cc.ReplaceAllString(honk.Noise, "") honk.Noise = strings.Replace(honk.Noise, "<a href=", "<a class=\"mention u-url\" href=", -1) }@@ -463,6 +466,8 @@ var re_avatar = regexp.MustCompile("avatar: ?([^\n]+)")
var re_banner = regexp.MustCompile("banner: ?([^\n]+)") var re_convoy = regexp.MustCompile("convoy: ?([^\n]+)") var re_retag = regexp.MustCompile("tags: ?([^\n]+)") +var re_cc = regexp.MustCompile("cc: ?([^\n]+)") +var re_link = regexp.MustCompile("link: ?([^\n]+)") var re_convalidate = regexp.MustCompile("^(https?|tag|data):") func memetize(honk *Honk) {