From d11ce38a6f3d1a80ca11284b346e29637d753318 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 27 Jul 2020 00:30:01 -0400 Subject: [PATCH] better outbound emoji --- activity.go | 16 ++++++++++++++++ fun.go | 22 +++++++++++++--------- web.go | 2 +- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/activity.go b/activity.go index 905d284..1acb6b8 100644 --- a/activity.go +++ b/activity.go @@ -1306,6 +1306,22 @@ func chonkifymsg(user *WhatAbout, ch *Chonk) []byte { if len(atts) > 0 { jo["attachment"] = atts } + var tags []junk.Junk + for _, e := range herdofemus(ch.Noise) { + t := junk.New() + t["id"] = e.ID + t["type"] = "Emoji" + t["name"] = e.Name + i := junk.New() + i["type"] = "Image" + i["mediaType"] = "image/png" + i["url"] = e.ID + t["icon"] = i + tags = append(tags, t) + } + if len(tags) > 0 { + jo["tag"] = tags + } j := junk.New() j["@context"] = itiswhatitis diff --git a/fun.go b/fun.go index d887689..7d8b0ea 100644 --- a/fun.go +++ b/fun.go @@ -177,19 +177,23 @@ func replaceimgsand(zap map[string]bool, absolute bool) func(node *html.Node) st } } -func filterchonk(ch *Chonk) { +func translatechonk(ch *Chonk) { + noise := ch.Noise + if ch.Format == "markdown" { + noise = markitzero(noise) + } var htf htfilter.Filter htf.SpanClasses = allowedclasses htf.BaseURL, _ = url.Parse(ch.XID) - noise := ch.Noise - local := false - if ch.Format == "markdown" { - noise = markitzero(noise) - local = true - } - ch.HTML, _ = htf.String(noise) - noise = string(ch.HTML) +} + +func filterchonk(ch *Chonk) { + translatechonk(ch) + + noise := string(ch.HTML) + + local := originate(ch.XID) == serverName zap := make(map[string]bool) emuxifier := func(e string) string { diff --git a/web.go b/web.go index 212b114..c2ac7ee 100644 --- a/web.go +++ b/web.go @@ -1825,7 +1825,7 @@ func submitchonk(w http.ResponseWriter, r *http.Request) { ch.Donks = append(ch.Donks, d) } - filterchonk(&ch) + translatechonk(&ch) savechonk(&ch) // reload for consistency ch.Donks = nil