1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-06 04:54:53 +02:00

Format emojis in the service worker directly

This commit is contained in:
nimbleghost 2023-05-31 18:27:32 +02:00
parent 44913c1668
commit 4648f83669
12 changed files with 85 additions and 112 deletions
server

View file

@ -2,8 +2,6 @@ package server
import (
"context"
_ "embed" // required by go:embed
"encoding/json"
"fmt"
"heckel.io/ntfy/util"
"io"
@ -135,25 +133,3 @@ func maybeDecodeHeader(header string) string {
}
return decoded
}
var (
//go:embed "mailer_emoji_map.json"
emojisJSON string
)
func toEmojis(tags []string) (emojisOut []string, tagsOut []string, err error) {
var emojiMap map[string]string
if err = json.Unmarshal([]byte(emojisJSON), &emojiMap); err != nil {
return nil, nil, err
}
tagsOut = make([]string, 0)
emojisOut = make([]string, 0)
for _, t := range tags {
if emoji, ok := emojiMap[t]; ok {
emojisOut = append(emojisOut, emoji)
} else {
tagsOut = append(tagsOut, t)
}
}
return
}