better outbound emoji

This commit is contained in:
Ted Unangst 2020-07-27 00:30:01 -04:00
parent 34adc4b8dc
commit d11ce38a6f
3 changed files with 30 additions and 10 deletions

View File

@ -1306,6 +1306,22 @@ func chonkifymsg(user *WhatAbout, ch *Chonk) []byte {
if len(atts) > 0 { if len(atts) > 0 {
jo["attachment"] = atts 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 := junk.New()
j["@context"] = itiswhatitis j["@context"] = itiswhatitis

22
fun.go
View File

@ -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 var htf htfilter.Filter
htf.SpanClasses = allowedclasses htf.SpanClasses = allowedclasses
htf.BaseURL, _ = url.Parse(ch.XID) 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) 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) zap := make(map[string]bool)
emuxifier := func(e string) string { emuxifier := func(e string) string {

2
web.go
View File

@ -1825,7 +1825,7 @@ func submitchonk(w http.ResponseWriter, r *http.Request) {
ch.Donks = append(ch.Donks, d) ch.Donks = append(ch.Donks, d)
} }
filterchonk(&ch) translatechonk(&ch)
savechonk(&ch) savechonk(&ch)
// reload for consistency // reload for consistency
ch.Donks = nil ch.Donks = nil